Call commands from stacks?

Are you using LiveCode to create server scripts or CGIs?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
pink
Posts: 285
Joined: Wed Mar 12, 2014 6:18 pm

Call commands from stacks?

Post 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?
Greg (pink) Miller

MadPink, LLC
I'm Mad, Pink and Dangerous to Know
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10103
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Call commands from stacks?

Post by FourthWorld »

Yep: "start using" to make all handlers in a stack available as a library works on servers as well.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3582
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Call commands from stacks?

Post 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.
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10103
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Call commands from stacks?

Post 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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3582
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Call commands from stacks?

Post 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.
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10103
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Call commands from stacks?

Post 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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3582
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Call commands from stacks?

Post 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
Post Reply