Page 1 of 3
Complete Newbie (but 25 years experience in older stuff)
Posted: Fri Jul 28, 2017 2:09 pm
by J&R Rovers
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
Re: Complete Newbie (but 25 years experience in older stuff)
Posted: Fri Jul 28, 2017 2:27 pm
by shaosean
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
Re: Complete Newbie (but 25 years experience in older stuff)
Posted: Fri Jul 28, 2017 2:34 pm
by Klaus
Shouldn't we add a line to make it really work?
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
Re: Complete Newbie (but 25 years experience in older stuff)
Posted: Fri Jul 28, 2017 2:59 pm
by shaosean
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
Re: Complete Newbie (but 25 years experience in older stuff)
Posted: Sat Jul 29, 2017 4:36 am
by J&R Rovers
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
Re: Complete Newbie (but 25 years experience in older stuff)
Posted: Sat Jul 29, 2017 6:56 am
by shaosean
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
Re: Complete Newbie (but 25 years experience in older stuff)
Posted: Sat Jul 29, 2017 8:42 am
by J&R Rovers
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
Re: Complete Newbie (but 25 years experience in older stuff)
Posted: Sat Jul 29, 2017 8:42 am
by J&R Rovers
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
Re: Complete Newbie (but 25 years experience in older stuff)
Posted: Sat Jul 29, 2017 10:08 am
by jmburnod
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
Best regards
Jean-Marc
Re: Complete Newbie (but 25 years experience in older stuff)
Posted: Sat Jul 29, 2017 10:54 am
by shaosean
Remove "private", seems send doesn't work with it..
not
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
Re: Complete Newbie (but 25 years experience in older stuff)
Posted: Sat Jul 29, 2017 10:57 am
by Klaus
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

Re: Complete Newbie (but 25 years experience in older stuff)
Posted: Sat Jul 29, 2017 11:35 am
by shaosean
aww.. You're forgiven schnucki..

Re: Complete Newbie (but 25 years experience in older stuff)
Posted: Sat Jul 29, 2017 11:40 am
by J&R Rovers
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
Re: Complete Newbie (but 25 years experience in older stuff)
Posted: Sat Jul 29, 2017 11:42 am
by Klaus
shaosean wrote:aww.. You're forgiven schnucki..

Merci, cherie!

Re: Complete Newbie (but 25 years experience in older stuff)
Posted: Sat Jul 29, 2017 11:46 am
by J&R Rovers
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