monte at sweattechnologies.com
Mon Feb 14 15:59:03 CST 2011
On 15/02/2011, at 7:01 AM, Peter Haworth wrote:
> My front scripts are now working OK after I addedd "of stack "xyz" to my insert commands as Jacqueline suggested.
> However, it looks like I have some wholesale changes to make to get my stackFiles working correctly with regard to my behavior scripts. The buttons that hold the behavior scripts are in a substack. I've included the name of the behaviors substack and it's main stack in the stackfiles, both pointing to the same file path but the behaviors still aren't recognised by the controls that point to them. I tried putting just the main stack into stackFiles and adding the statement "open stack "xyzsub of stack "xyz" - the behaviors still aren't recognised.
> The behaviors are specified in the form "button id 1234 of stack "xyzSub". I tried adding "of stack "xyz" after the behavior specifications but the IDE simply removes that text.
> At this point, it feels like I will have to put the behaviors onto a card in its own mainstack. The problem with that, I think, is that all the behavior buttons will end up with new IDs and I'll be left with hundreds of controls that point to a non-existant button ID. I guess I could write a script to go through all the controls that have behaviors and put the correct button IDs into them but looking for other suggestions before I do that.
If you set the mainstack of the behaviors substack to itself and save it the ids won't change so that's a possibility. Probably the simplest thing to do is to leave everything as is and load the stackfile into memory at startup. From then on you can refer to all the stacks by name. You could hard code a relative path here and forget about stackfiles completely. Even better is to have a components folder that you parse the files of and load all stacks into memory. For added simplicity you could start using any stacks that have lib as the first 3 chars of their name. But to get you out of this hole just using something like this will load the stackfile:
get the short name of stack whatever
It sounds like there's an issue with the loading of behaviors via the stackfiles property if it's not doing what the docs say it should.
Probably one last point to make is Trevor's excellent GLX application framework will handle all this stuff for you.
More information about the use-livecode