Page 1 of 1

Call commands from stacks?

Posted: Thu Sep 10, 2015 9:43 pm
by pink
I have a Livecode stack that I started copying chunks of code out of to use in a server script.

Problem is that I keep making changes to the code in the stack, and then I need to update the scripts.

Can I just include the stack and run commands out of it in a server script?

Re: Call commands from stacks?

Posted: Thu Sep 10, 2015 10:10 pm
by FourthWorld
Yep: "start using" to make all handlers in a stack available as a library works on servers as well.

Re: Call commands from stacks?

Posted: Mon Mar 21, 2016 5:08 am
by mwieder
Interestingly, it appears that the preOpenStack handler is *not* called when you "start using" a stack. I'm not sure at the moment if this is an oversight, if I'm expecting too much out of the server configuration, or if this is by design.

Re: Call commands from stacks?

Posted: Mon Mar 21, 2016 5:26 am
by FourthWorld
mwieder wrote:Interestingly, it appears that the preOpenStack handler is *not* called when you "start using" a stack.
True
Since HCIL the message sent to a library brought into use is libraryStack.

Re: Call commands from stacks?

Posted: Mon Mar 21, 2016 5:31 am
by mwieder
Yeah. I'm now dispatching to my preOpenStack handler in the card script from the libraryStack handler in the stack script in order to get a frontscript in play. I know startup will get called instead of preOpenStack in standalones, but I rather expected that the server would call preOpenStack when launching a stack. Makes it slightly harder to get a one-size-fits-all stack that works with either the desktop or server engines.

Re: Call commands from stacks?

Posted: Mon Mar 21, 2016 2:30 pm
by FourthWorld
mwieder wrote:Yeah. I'm now dispatching to my preOpenStack handler in the card script from the libraryStack handler in the stack script in order to get a frontscript in play. I know startup will get called instead of preOpenStack in standalones, but I rather expected that the server would call preOpenStack when launching a stack. Makes it slightly harder to get a one-size-fits-all stack that works with either the desktop or server engines.
If the stack is a library "libraryStack" should be automatically called in either Server or the desktop when the stack is brought into use.

Re: Call commands from stacks?

Posted: Mon Mar 21, 2016 3:33 pm
by mwieder
Richard- yeah, I realize that, but what I was trying to do in this case is launch a stack created with the IDE. If it were just a library I would have made it a script-only stack. The stack does have a button whose script gets installed as a frontscript, and I have been using the preOpenStack handler to insert the script when the stack is launched in the IDE. So now for the server I have added

Code: Select all

on libraryStack
  dispatch "preOpenStack" to card 1 of me
end libraryStack