[Solved] Standalone loading script into back

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

[Solved] Standalone loading script into back

Post by Zax » Wed May 24, 2017 9:59 am

Hello,

I have stack with a substack, which is a personal script library.
The following script is in the main stack:

Code: Select all

on preOpenStack
    insert the script of stack "MyLibStack" into back
end preOpenStack

on openStack
   answer the backScripts // just to be sure script of "MyLibStack" has been loaded
   answer myFunction("test") // myFunction() is in the substack "MyLibStack"
end openStack
This code works in development environment, and it also worked with others personal standalone appls. But with my current stack, it doesn't in standalone environment. It crashes on startup at line containing "myFonction" with a "Type: Handler: can't find handler".
It looks like the script of "MyLibStack" has NOT been loaded, though "MyLibStack" appears in the backScripts.
Using LC Community 8.14

Of course, I can put the scripts of "MyLibStack" in the main stack, and remove "MyLibStack", but I would like to understand what is happening.

(sorry in advance, maybe I'll not be able to check this thread for a few days)


EDIT: when the startup process is completed, any call to script in "MyLibStack" substack works.
Last edited by Zax on Sat May 27, 2017 10:26 pm, edited 1 time in total.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: [Help] Standalone loading script into back

Post by jmburnod » Wed May 24, 2017 3:16 pm

Hi Zax,
I tested your script and it works for me (LC 8.1.3 indy stable, OS X Sierra 10.10.3)
Best regards
Jean-Marc
https://alternatic.ch

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Re: [Help] Standalone loading script into back

Post by Zax » Thu May 25, 2017 11:27 am

Hello Jean-Marc,

As I said, I used to use something like MyLibStack on others stacks and standalones without any problem. I really don't understand why the scripts in back are not correctly loaded during startup.
Inclusions are correct because calling handlers to MyLibStack after startup process works fine.

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: [Help] Standalone loading script into back

Post by Klaus » Thu May 25, 2017 12:54 pm

Hi Zax,

the scripts are loading slower than you think, deopends on the library of course!

So at "openstack" only the "index" of "stuff to load" has been loaded, as you experienced,
but not all of the libs themselves.

To avoid this inconvenence, give LC just a tad more time like this:

Code: Select all

on preOpenStack
    insert the script of stack "MyLibStack" into back
end preOpenStack

on openStack
   ## 1 tick "delay" should be sufficient
   send "my_lib_stuff" to me in 1
end openStack

command my_lib_stuff
   answer the backScripts // just to be sure script of "MyLibStack" has been loaded
   answer myFunction("test") // myFunction() is in the substack "MyLibStack"
end my_lib_stuff
Best

Klaus

Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Re: [Help] Standalone loading script into back

Post by Zax » Thu May 25, 2017 6:02 pm

Klaus wrote: send "my_lib_stuff" to me in 1
Yeah, it works :)

Thank you very much.

Post Reply