Thanks for the pointers Tereza.

I think the cause of most of my problems was the existence of two stacks with the same name, as you pointed out. After fixing that issue, I now have this working fine.

Instead of passing in the name of the app stack, I found I could the use "the long name of this stack", eg:

set the mainstack of stack "Structures" to the mainstack of the long name of this stack

I also figured out what you recommended for the code to create the stack.

Pete Haworth








On Apr 17, 2010, at 9:42 AM, [email protected] wrote:



Message: 1
Date: Fri, 16 Apr 2010 18:13:26 -0500
From: Tereza Snyder <[email protected]>
Subject: Re: Referencing a stack from a front script
To: How to use Revolution <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset=us-ascii


On Apr 16, 2010, at 1:50 PM, Peter Haworth wrote:

My app inserts some front scripts from a separate .rev file, then calls a handler in the front script that needs to reference the application's .rev file, specifically to create a stack as a substack of the application's main stack if it doesn't already exist , then add several cards to it.

Up to now, the front scripts have been in the same .rev file as my app and the code to achieve the above worked fine. I have now broken them out into a separate code library .rev file and things don;t work correctly any more.

I've tried so many combinations of "this stack", the long name of this stack", etc that I've lost track of what happened with each of them, suffice it to say that none of them had the desired effect. The .rev file holding the front scripts happens to have a stack with the same name as the stack I want to create in the application's .rev file and I have not been able to figure out how to have the check for the existence of this stack look in the app's .rev file instead of the front scripts .rev file.

In desperation, I created the stack in the app's .rev file in the IDE, but now how do I tell the create card command in the front script to put the new card into the stack in the app's .rev file - that command doesn't seem to have a way to name the stack you want to create the card in other than what is in the defaultStack and it appears defaultStack can only be set the a local stack name.

First, having two stacks with the same name in memory is a no-no. Change your strategy so that it never happens.

Second, communicate the app stack's name to the handler. If possible, send a parameter with the stack's name to the handler, or set a property on the object to which the front script belongs and have the handler check for (something like) "the uTargetStackName" of me", or put the stack's name in a global.


Third, in your handler, create your new substack, set its mainStack to the app stack. Store the value of the defaultStack, set the defaultStack to the new substack, create your cards, and reset the defaultStack.

I don't know if it suits your design, but I'd put my library code in a stack script, and make a prototype substack of that library stack and call it something like "xxxTemplate" . Then, in the make-a- substack-and-create-cards handler I would clone that stack with 'clone stack "xxxTemplate"', then set the name of it to "xxx", then set its mainstack as above.


t






--
Tereza Snyder
Califex Software, Inc.
<www.califexsoftware.com>


_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to