Complete Newbie (but 25 years experience in older stuff)

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

J&R Rovers
Posts: 19
Joined: Thu Feb 26, 2015 7:51 am
Location: Perth, Western Australia
Contact:

Complete Newbie (but 25 years experience in older stuff)

Post by J&R Rovers » Fri Jul 28, 2017 2:09 pm

Hi All
After so many years programming in GWBasic - Quick Basic - dBase - Foxbase - Foxpro - Visual Foxpro it is indeed humbling to be brought up short and have to learn to crawl again. I wonder if it might be easier for a non programmer to learn Livecode without the constraints of old knowledge and habits.
However I have the greatest admiration for Livecode and what the team have produced, it is nothing short of amazing that a small company can pull of what we have been waiting for for years. A simplified multi platform programming environment. I managed to produce and compile a working app using sqlLite within a few days after a week of study. Admittedly it was a Windows app which is familiar territory for me, but it ran without error and produced queries into a grid without a hitch. Maybe an Android compile will produce a few more challenges.
What's more I was pleasantly surprised by the speed of loading and running of queries. Amazing !
I have one small request maybe someone could help me with please. I have partly built an incremental search field that displays queries into a grid while the user is typing. At this stage the user can't type any more than one letter at a time. I would like to have it allow the user to continue and the query to only kick in when they stop typing (for more than say .5 or 1 second). Here is the code, please excuse how cumbersome it is (but it works !):
on keyDown pKey
put toUpper(pKey) into the selection
end keyDown

on keyUp

global gConID
#// Empty the grid
set the dgData of group "DataGrid1" to empty

put field "fldEntry" into myField
put "%" after myField
#// insert some code in here that will prevent the query from happening
#// until a set period of time after the user stops typing (say 1 second)
put "SELECT * FROM customers where customerid like " into tQuery
put "'" after tQuery
put myField after tQuery
put "'" after tQuery

put revDataFromQuery(,,gConID,tQuery) into tRecords
set the dgText of group "datagrid1" to tRecords

end keyUp

And if anyone can help with some docs on the hierarchy of folders produced by the compiler. There seems to be a lot more files than are needed for distribution.

Thank you in advance
Kind regards
John Stephen

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Complete Newbie (but 25 years experience in older stuff)

Post by shaosean » Fri Jul 28, 2017 2:27 pm

What you want to do is to use send to do your time delayed search.. When the KeyDown event is fired, check if the message is among the pendingMessages and if it is, then cancel it..

Code: Select all

local sMySendCommandID

on keyDown pKey
  if (sMySendCommandID is among the lines of the pendingMessages) then cancel sMySendCommandID
  send "MyDelayedSearch pKey" to me in 500 milliseconds
  put the result into sMySendCommandID
end keyDown

private command MyDelayedSearch pKey
  -- do your stuff here
end MyDelayedSearch
Last edited by shaosean on Fri Jul 28, 2017 3:00 pm, edited 1 time in total.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Complete Newbie (but 25 years experience in older stuff)

Post by Klaus » Fri Jul 28, 2017 2:34 pm

Shouldn't we add a line to make it really work? :D

Code: Select all

local sMySendCommandID

on keyDown pKey
  if (sMySendCommandID is among the lines of the pendingMessages) then cancel sMySendCommandID
  send "MyDelayedSearch pKey" to me in 500 milliseconds
  put the result into sMySendCommandID
end keyDown

private command MyDelayedSearch pKey
  -- do your stuff here
end MyDelayedSearch

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Complete Newbie (but 25 years experience in older stuff)

Post by shaosean » Fri Jul 28, 2017 2:59 pm

I knew I forgot something, but couldn't see what it was ;-) I'll edit my code as well that way if someone copies it, it won't be a cruise on the fail boat

J&R Rovers
Posts: 19
Joined: Thu Feb 26, 2015 7:51 am
Location: Perth, Western Australia
Contact:

Re: Complete Newbie (but 25 years experience in older stuff)

Post by J&R Rovers » Sat Jul 29, 2017 4:36 am

Thank you, I am really sorry guys but I couldn't make this work. I confess to not understanding the comment by Klaus regarding the extra line, I couldn't see one. Here is the code as I interpreted it. It now does nothing, the character entered does not echo, the field stays blank and nothing happens
local sMySendCommandID

on keyDown pKey
if (sMySendCommandID is among the lines of the pendingMessages) then cancel sMySendCommandID
send "MyDelayedSearch pKey" to me in 500 milliseconds
put the result into sMySendCommandID
end keyDown

private command MyDelayedSearch pKey
-- do your stuff here
global gConID
set the dgData of group "DataGrid1" to empty
put field "fldEntry" into myField
put "%" after myField

put "SELECT * FROM customers where customerid like " into tQuery
put "'" after tQuery
put myField after tQuery
put "'" after tQuery

put revDataFromQuery(,,gConID,tQuery) into tRecords
set the dgText of group "datagrid1" to tRecords

end MyDelayedSearch
Where did I go wrong ?
Cheers
John

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Complete Newbie (but 25 years experience in older stuff)

Post by shaosean » Sat Jul 29, 2017 6:56 am

Klaus' message about the missing line was because I missed the line "put the result into sMySendCommandID" in my original posting.. Seems we both missed the "pass KeyDown" as well..

Code: Select all

on keyDown pKey
  if (sMySendCommandID is among the lines of the pendingMessages) then cancel sMySendCommandID
  send "MyDelayedSearch pKey" to me in 500 milliseconds
  put the result into sMySendCommandID
  pass keyDown  -- this is the line we both missed
end keyDown
OR use the keyUp event instead

Code: Select all

on keyUp pKey
  if (sMySendCommandID is among the lines of the pendingMessages) then cancel sMySendCommandID
  send "MyDelayedSearch pKey" to me in 500 milliseconds
  put the result into sMySendCommandID
end keyUp

J&R Rovers
Posts: 19
Joined: Thu Feb 26, 2015 7:51 am
Location: Perth, Western Australia
Contact:

Re: Complete Newbie (but 25 years experience in older stuff)

Post by J&R Rovers » Sat Jul 29, 2017 8:42 am

No that does nothing either, but thank you for trying to help
Perhaps you could help me with something else. I am trying to use the debugger, but it won't switch on and breakpoints are in grey not red and are ignored. Is there a switch somewhere that disables the debugger ? I can find nothing in any documentation and in the demos the debugger just works. I am using Indy version 8.1.5. I have seen it working once, but I have no idea what made it work.
If I can get that going I am sure I can work something out even using my old programming logic.
Thanks and cheers
John

J&R Rovers
Posts: 19
Joined: Thu Feb 26, 2015 7:51 am
Location: Perth, Western Australia
Contact:

Re: Complete Newbie (but 25 years experience in older stuff)

Post by J&R Rovers » Sat Jul 29, 2017 8:42 am

No that does nothing either, but thank you for trying to help
Perhaps you could help me with something else. I am trying to use the debugger, but it won't switch on and breakpoints are in grey not red and are ignored. Is there a switch somewhere that disables the debugger ? I can find nothing in any documentation and in the demos the debugger just works. I am using Indy version 8.1.5. I have seen it working once, but I have no idea what made it work.
If I can get that going I am sure I can work something out even using my old programming logic.
Thanks and cheers
John

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2718
Joined: Sat Dec 22, 2007 5:35 pm
Location: Genève
Contact:

Re: Complete Newbie (but 25 years experience in older stuff)

Post by jmburnod » Sat Jul 29, 2017 10:08 am

Hi John,
Is there a switch somewhere that disables the debugger ?
Maybe menu development>script debug mode
breakpoints are in grey not red and are ignored
You can enable/disable a breakpoint with a contextual menu
clic-ctrl. You can even put a condition 8)
Best regards
Jean-Marc
https://alternatic.ch

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Complete Newbie (but 25 years experience in older stuff)

Post by shaosean » Sat Jul 29, 2017 10:54 am

Remove "private", seems send doesn't work with it..

Code: Select all

command MyDelayedSearch
not

Code: Select all

private command MyDelayedSearch

Code: Select all

local sMySendCommandID

on keyDown pKey
   --    if (sMySendCommandID is among the lines of the pendingMessages) then cancel sMySendCommandID
   send "MyDelayedSearch pKey" to me in 500 milliseconds
   put the result into sMySendCommandID
   pass keyDown
end keyDown

command MyDelayedSearch pKey
   -- do your stuff here
   put pKey
end MyDelayedSearch

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Complete Newbie (but 25 years experience in older stuff)

Post by Klaus » Sat Jul 29, 2017 10:57 am

shaosean wrote:Klaus' message about the missing line was because I missed the line "put the result into sMySendCommandID" in my original posting.. Seems we both missed the "pass KeyDown" as well..
Ouch, yes :oops:

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Complete Newbie (but 25 years experience in older stuff)

Post by shaosean » Sat Jul 29, 2017 11:35 am

aww.. You're forgiven schnucki.. :D

J&R Rovers
Posts: 19
Joined: Thu Feb 26, 2015 7:51 am
Location: Perth, Western Australia
Contact:

Re: Complete Newbie (but 25 years experience in older stuff)

Post by J&R Rovers » Sat Jul 29, 2017 11:40 am

Ha ha, works now - sort of. If I type two letters in quick succession it flashes the result up twice the first time it flashes and disappears, then the second time shows the result (correctly) Is there a way of avoiding the first refresh ?
Thanks and cheers
John

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Complete Newbie (but 25 years experience in older stuff)

Post by Klaus » Sat Jul 29, 2017 11:42 am

shaosean wrote:aww.. You're forgiven schnucki.. :D
Merci, cherie! :P

J&R Rovers
Posts: 19
Joined: Thu Feb 26, 2015 7:51 am
Location: Perth, Western Australia
Contact:

Re: Complete Newbie (but 25 years experience in older stuff)

Post by J&R Rovers » Sat Jul 29, 2017 11:46 am

Regarding the illusive debug mode the Development - Script Debug Mode menu item is ignored in both Edit and Run mode. Ctrl - Click placing the breakpoint still results in a grey mark and nothing stops
Cheers
John

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”