Scope Problem on Standalones

David Burgun dburgun at dsl.pipex.com
Fri Nov 25 08:34:28 EST 2005


Hi,

I have an application that is comprised on a number of stacks.

The top level stack is built into a Standalone and it calls other 
stacks (.rev files) via "start using" and "go stack" commands.

When in the IDE the folder stucture is like this:

BaseFolder/StartUp.rev <-- just contains a splash screen
BaseFolder/Runtime/Stacks/StackA.rev
BaseFolder/Runtime/Stacks/StackB.rev
BaseFolder/Runtime/Stacks/StackC.rev

StartUp.rev figures out the correct path (by using the filename of 
this stack property) and does a goto StackA.rev.
StackA in turn does a go to StackB.rev. This all works fine under the IDE.

When runnig as a standalone the folder structure is like this:

MacOSX/myApp.app  <-- bundle
MacOSX/myApp.app/Contents/MacOS/MyApp (real applicaiton)
MacOSX/myApp.app/Contents/MacOS/Runtime/Stacks/StackA.rev
MacOSX/myApp.app/Contents/MacOS/Runtime/Stacks/StackB.rev
MacOSX/myApp.app/Contents/MacOS/Runtime/Stacks/StackC.rev


But when I run this StackB.rev does not get found/run.

I traced this down to some code in card 1 (the only card) of StackA.rev:


function LoadGlobalStacks
   local myStackFIlePathName
   local myStackFIlePath
   local myGlobalStackFilePathName

put the filename of this stack into myStackFIlePathName
put myStackFIlePathName into myStackFIlePath
set itemDelimiter to :/"
delete item -1 of myStackFIlePath
set itemDelimiter to ","

put myStackFIlePath & "/StackB.rev" into myGlobalStackFilePathName
if there is not a stack myGlobalStackFilePathName return false

start using myGlobalStackFilePathName

return true
end LoadGlobalStacks


on preOpenStack
    if LoadGlobalStacks() = false then
   answer error "Cannot Find Global Stacks"
   end if

set the menubar of this stack to "MainMenu"

end preOpenStack


The problem seems to be that in the LoadGlobalStacks() function the 
string returned from:

put the filename of this stack into myStackFIlePathName

is "MacOSX/myApp.app" and not

"MacOSX/myApp.app/Contents/MacOS/Runtime/Stacks/StackA.rev" as expected.

I am guessing it's something to do with scope and being called from a 
preOpenStack handler??? StackA.rev was enetered via a go stack 
path/StackA from MacOSX/myApp.app and it looks like this context is 
being used instead of the context of StackA.rev.

If so, what is the recommended way of doing this?? If not what am I 
doing wrong?

Thanks in advance for any help.

All the Best
Dave



















More information about the use-livecode mailing list