Simple Scoping Question

David Burgun dburgun at dsl.pipex.com
Wed Apr 20 13:53:10 EDT 2005


Hi,

Ok, I think I have found the problem! I have a openStack handler in 
the script of the Stack,  as so:

on openStack
local myStackFileName,myStackShortName,myGlobalStackName

put the fileName of this stack into myStackFileName
put the short name of this stack into myStackShortName
put replaceText(myStackFileName, myStackShortName,"GlobalStack" into 
myGlobalStackName

set the cpGlobalStackFileName to myGlobalStackName   --*****Breakpoint here

--start using stack myGlobalStackName  -Commented out to stop crashing

end openStack


on closeStack
if the cpGlobalStackFileName of this stack  <> empty
   -- stop using stack the cpGlobalStackFileName of this stack 
-Commented out to stop crashing
   set the cpGlobalStackFileName to empty
end if
end closeStack

---------------------------------------

The Stack is closed and then I re-open it and hit the breakpoint and 
the variables are set as you would expect and I think the start using 
line would work ok.

I then hit run and then Save the Stack and hit the breakpoint again, 
this time the variables are set as follows:

myStackFileName     - empty
myStackShortName  - empty
myGlobalStackName  - revSaving

I hadn't realized that the openStack handler gets called when doing a 
Save. What is the recommended action for handle this?

I could do one of three things:

1.  Check if myStackFileName is empty and if so skip the "start uisng"
2.  Check the Stack Name for "revSaving" and if so skip the "start uisng"
3.  Check if in "development" moce and if so  skip the "start uisng"

I suppose I need similar tests in preOpenStack and closeStack?

Can anyone tell me the best thing to do under this condition?

Thanks in advance.
Dave


>Hi Dave,
>
>No.
>But a statement setting the defaultStack property yes.
>Best,
>
>Le 20 avr. 05, à 18:41, David Burgun a écrit :
>
>>Hi,
>>
>>That's how I thought it would work. I am getting very strange results
>>from code that does this tho. Could the Current Stack be being lost
>>as a result of calling "Answer" or put xxx into msg box?
>>
>>Thanks
>>Dave
>>
>>>Hi Dave,
>>>
>>>In any script of stack A, if you call a function placed in the
>>>script of stack B, *this* will refer to stack A since your script
>>>has been initiated in stack A.
>>>Function or handler places do not matter.
>>>The only important point is: from where do I began :-)
>>>
>>>Le 20 avr. 05, à 17:33, David Burgun a écrit :
>>>
>>>>>Hi Dave,
>>>>>
>>>>>>e.g. if Stack A
>>>>>>
>>>>>>does a start using start using stack "GlobalStack"
>>>>>>
>>>>>>and thean Stack A calls a Function in "GlobalStack" that refers
>>>>>>to "this stack" does that refer to "Stack A" or "GlobalStack" ?
>>>>>>
>>>>>>Does this work the same way if the Stacks in question are both
>>>>>>main stacks and does it work the same way in a Standalone
>>>>>>Application?
>>>>>
>>>>>"This" always refers to "the currently selected", whether
>>>>>referencing stacks, cards, groups, or individual controls.
>>>>>Substitute
>>>>>'stack "GlobalStack"' for "this stack" in GlobalStack's stack script.
>>>>>
>>>>>Rob Cozens, Staff Conservator
>>>>>Mendonoma Marine Life Conservancy
>>>>
>>>>Hi,
>>>>
>>>>I am confused, in the case where "StackA" calls a Function in
>>>>"GlobalStack", when in that function should "this stack" return
>>>>"StackA" or "GlobalStack" ?
>>>>
>>>>I want it to return "StackA" so that the functions are general.
>
>Amicalement,
>
>Eric Chatonet.
>----------------------------------------------------------------
>So Smart Software
>
>For institutions, companies and associations
>Built-to-order applications: management, multimedia, internet, etc.
>Windows, Mac OS and Linux... With the French touch
>----------------------------------------------------------------
>Web site		http://www.sosmartsoftware.com/
>Email		eric.chatonet at sosmartsoftware.com/
>Phone		33 (0)1 43 31 77 62
>Mobile		33 (0)6 20 74 50 86
>----------------------------------------------------------------
>
>_______________________________________________
>use-revolution mailing list
>use-revolution at lists.runrev.com
>http://lists.runrev.com/mailman/listinfo/use-revolution



More information about the use-livecode mailing list