How to force a handler to finish it's job before proceeding with something else

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: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

sphere
Posts: 849
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: How to force a handler to finish it's job before proceeding with something else

Post by sphere » Sat Apr 13, 2019 1:08 pm

Hallo Axwald

I had a play yesterday with your script.
WIth your sqlite db it is indeed blistering fast.

I made a separate db with my data and if i change the db and column names accordingly in your test stack then it gives an error --> near ";": syntax error and the text from clipboard is then --> INSERT INTO `mydb` (`id`,`yo`,`man`) VALUES
;

if i omit the semicolon then it gies --> Your query failed! Reason: incomplete input.

2nd I tested with embedding my sqlite db in the stack, now in the IDE it sees the file (i check) and puts it perfectly in the DG.
But on Android it does see the file (i have to use specialfolder("engine") ), but does not do anything further with it. (yes all standalone dependencies are selected).

Code: Select all

put specialFolderPath("engine") & "/mydb.sqlite" into tHistDB
   if there is not a file tHistDB then
      answer "Local DB file not found" --just for test
   else
      if there is a file tHistDB then
      answer "Local DB file is here" --just for test
   put revOpenDatabase("sqlite", tHistDB, , , , ) into tLocalDbID
   put "SELECT * FROM mytable" into tSQp
   put revDataFromQuery(tab,return,tLocalDbID,tSQp) into tThis
and the rest to get it into the DG

Your stack also gave me another idea, of which i never did make use of till now and that is to add the data as a Customkey in the stack inspector and call it with the line: put the cData of this stack into theData. (never thought about it, because i always wanted to be able to update from external db)

For now this is good and also extremely fast.
And later on i can re-add the sqlite fast function when i want to add my further options to the stack. I takes minor adjustments then. So i have time to play with your written function further.

Thanks for your insights! I Appreciate it!
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

AxWald
Posts: 354
Joined: Thu Mar 06, 2014 2:57 pm

Re: How to force a handler to finish it's job before proceeding with something else

Post by AxWald » Mon Apr 15, 2019 7:16 pm

Hi,
sphere wrote:
Sat Apr 13, 2019 1:08 pm
WIth your sqlite db it is indeed blistering fast.
;-))
sphere wrote:
Sat Apr 13, 2019 1:08 pm
I made a separate db with my data and if i change the db and column names accordingly in your test stack then it gives an error --> near ";": syntax error and the text from clipboard is then --> INSERT INTO `mydb` (`id`,`yo`,`man`) VALUES
;
This looks like an empty VALUES list - makeSQLValues() must have returned an empty string (probably "the cData of this stack" are empty ...). Since this function hasn't any error handling it's assumed that the parameters are correct and the return value is checked - both tests are lacking in my stack, I admit :/
sphere wrote:
Sat Apr 13, 2019 1:08 pm
But on Android it does see the file (i have to use specialfolder("engine") ), but does not do anything further with it.
Careful with specialfolder("engine") - it's write-only on mobile. You may want to use "documents" (permanent data) or "cache" (data that are session specific) - only there you can write (i.e. INSERT into a db).
sphere wrote:
Sat Apr 13, 2019 1:08 pm
Your stack also gave me another idea, of which i never did make use of till now and that is to add the data as a Customkey
Custom properties are a great way to store data - and to react when the data changes, using setProp handlers. Right :)

Have fun!
Livecode programming until the cat hits the fan ...

sphere
Posts: 849
Joined: Sat Sep 27, 2014 10:32 am
Location: Earth, Except when i Jump

Re: How to force a handler to finish it's job before proceeding with something else

Post by sphere » Tue Apr 16, 2019 12:13 pm

Thanks for your help Axwald!
2018 Worldwide Mobile Market share: Android 84.4% !!!, iOs 15.1%, others 0.1%

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”