Page 1 of 1

[Solved] Standalone loading script into back

Posted: Wed May 24, 2017 9:59 am
by Zax
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.

Re: [Help] Standalone loading script into back

Posted: Wed May 24, 2017 3:16 pm
by jmburnod
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

Re: [Help] Standalone loading script into back

Posted: Thu May 25, 2017 11:27 am
by Zax
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.

Re: [Help] Standalone loading script into back

Posted: Thu May 25, 2017 12:54 pm
by Klaus
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

Re: [Help] Standalone loading script into back

Posted: Thu May 25, 2017 6:02 pm
by Zax
Klaus wrote: send "my_lib_stuff" to me in 1
Yeah, it works :)

Thank you very much.