Creating and using library stacks
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Creating and using library stacks
Ive created a stack of common items Id like to include in many apps.
Id like to be able to use it in the same was as animation engine, charts engine etc where I can just issue the command..
'start using stack mylibrarystack' and everything in the stack becomes available.
This works if the library stack is loaded in memory, but when I close the code down and re-open it the library stack is not automatically opened into memory, so the start using command fails.
What do I need to do to get the stack to load automatically on startup like the commercial add ons????
Thanks
Andy
Id like to be able to use it in the same was as animation engine, charts engine etc where I can just issue the command..
'start using stack mylibrarystack' and everything in the stack becomes available.
This works if the library stack is loaded in memory, but when I close the code down and re-open it the library stack is not automatically opened into memory, so the start using command fails.
What do I need to do to get the stack to load automatically on startup like the commercial add ons????
Thanks
Andy
Re: Creating and using library stacks
It is a bit tricky, in that LC wants to see certain files in certain places. I think Jacque sent me this recipe a while back:
1. Just make any stack you like, and add a preOpenStack handler in its card script to put the stack into use as a library:
on preOpenStack
start using this stack
end preOpenStack
You'll want to do this in the card script rather than the stack
script, since once the stack is brought into use as a library
any handlers in it will be triggered from any such messages.
2. Save the stack in a folder named "Plugins" in a folder named "LiveCode", somewhere, likely the "documents" folder:
~/Documents/LiveCode/Plugins/
3. You may need to quit Rev before your plugin is recognized; I
believe their Plugin manager is not as adept as MC's in allowing
you to add stuff to it on the fly.
4. Launch Rev, and choose Plugin Settings from the Development->Plugins menu.
5. Select your plugin stack from the popup list at the top of the
Plugins Manager, and choose the appropriate radio control for "Open plugin when: Revolution starts").
Navigate to the enclosing ("Livecode") folder in the files and memory pane of the LC preferences.
1. Just make any stack you like, and add a preOpenStack handler in its card script to put the stack into use as a library:
on preOpenStack
start using this stack
end preOpenStack
You'll want to do this in the card script rather than the stack
script, since once the stack is brought into use as a library
any handlers in it will be triggered from any such messages.
2. Save the stack in a folder named "Plugins" in a folder named "LiveCode", somewhere, likely the "documents" folder:
~/Documents/LiveCode/Plugins/
3. You may need to quit Rev before your plugin is recognized; I
believe their Plugin manager is not as adept as MC's in allowing
you to add stuff to it on the fly.
4. Launch Rev, and choose Plugin Settings from the Development->Plugins menu.
5. Select your plugin stack from the popup list at the top of the
Plugins Manager, and choose the appropriate radio control for "Open plugin when: Revolution starts").
Navigate to the enclosing ("Livecode") folder in the files and memory pane of the LC preferences.
Re: Creating and using library stacks
Craig...
Your take is interesting, in that, I use library stacks quite a lot... I too use a 'preOpenStack' handler to launch them, but have always put the 'preOpenStack' in the script of the stack... Have not had any problems with the handler placed there, both under OSX and windows...
be well,
Dixie
Your take is interesting, in that, I use library stacks quite a lot... I too use a 'preOpenStack' handler to launch them, but have always put the 'preOpenStack' in the script of the stack... Have not had any problems with the handler placed there, both under OSX and windows...
be well,
Dixie
Last edited by Dixie on Wed Aug 31, 2011 5:12 pm, edited 2 times in total.
Re: Creating and using library stacks
Thanks, it was item (1) that I was missing.
Ive added that and it works!
Andy
Ive added that and it works!
Andy
Re: Creating and using library stacks
Hi Andy,
you can also "start using stack XYZ" WITHOUT opening it first!
Just supply the correct (relative or absolute) filename of the stack:
...
start using stack "subfolder/theLib.rev"
...
Best
Klaus
you can also "start using stack XYZ" WITHOUT opening it first!
Just supply the correct (relative or absolute) filename of the stack:
...
start using stack "subfolder/theLib.rev"
...
Best
Klaus
Re: Creating and using library stacks
Dixie- technically the preOpenStack handler should reside in the script of the first card of the stack. For stacks with no substacks it doesn't make much difference, but if you have a preOpenStack (openStack, closeStack, openCard, etc...) handler in the script of the mainstack itself then it will get called when a substack opens as well. And this may not be what you want and cause unforseen consequences, forcing you to do ugly things like
The first card of the stack is guaranteed to get the preOpenStack (openStack, etc...) messages, and if not handled there it will be passed down to the stack script.
Code: Select all
on preOpenStack
if the name of this stack is the name of stack the mainStack of this stack then
...