Call commands from stacks?

Are you using LiveCode to create server scripts or CGIs?

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

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

Call commands from stacks?

Post by pink » Thu Sep 10, 2015 9:43 pm

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: 5462
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Call commands from stacks?

Post by FourthWorld » Thu Sep 10, 2015 10:10 pm

Yep: "start using" to make all handlers in a stack available as a library works on servers as well.
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2588
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Call commands from stacks?

Post by mwieder » Mon Mar 21, 2016 5:08 am

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: 5462
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Call commands from stacks?

Post by FourthWorld » Mon Mar 21, 2016 5:26 am

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
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2588
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Call commands from stacks?

Post by mwieder » Mon Mar 21, 2016 5:31 am

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: 5462
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Call commands from stacks?

Post by FourthWorld » Mon Mar 21, 2016 2:30 pm

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
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2588
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Call commands from stacks?

Post by mwieder » Mon Mar 21, 2016 3:33 pm

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

Return to “CGIs and the Server”