Some clues... (and 3 handlers)
David Bovill
david at openpartnership.net
Tue Jan 23 06:25:18 EST 2007
Thanks for that Jack - in response here are 3 handlers you can use to check
stacks without getting these error messages and without ending up with them
loaded into memory:
function stack_Exists someName
-- will not add stack to memory
set lockmessages to true
put the mainstacks into stacksInMemory
put empty into shortStackName
if exists(stack someName) then
put true into safeExistence
put not(shortStackName is among the lines of stacksInMemory) into
needToClose
if needToClose then
stack_CloseMain someFile
end if
else
put false into safeExistence
end if
set lockmessages to false
return safeExistence
end stack_Exists
function stack_GetShortName someName
-- will not add stack to memory
set lockmessages to true
put the mainstacks into stacksInMemory
put empty into shortStackName
if exists(stack someName) then
put the filename of stack someName into someFile
put the short name of stack someName into shortStackName
put not(shortStackName is among the lines of stacksInMemory) into
needToClose
if needToClose then
stack_CloseMain someFile
end if
end if
set lockmessages to false
return shortStackName
end stack_GetShortName
function stack_GetFileName someName
-- will not add stack to memory
set lockmessages to true
put the mainstacks into stacksInMemory
put empty into someFile
if exists(stack someName) then
put the filename of stack someName into someFile
put the short name of stack someName into shortStackName
put not(shortStackName is among the lines of stacksInMemory) into
needToClose
if needToClose then
stack_CloseMain someFile
end if
end if
set lockmessages to false
return someFile
end stack_GetFileName
Now my question is if there can be a confusion with stacks of the same name
- while the above handlers do not set anything so are safe I think - where
and when exactly can things o wrong? As an example:
set the name of stack somefile
Would I guess always work as expected (even if there are two stacks in
memory with the same short name). So is there never any harm if you refer to
things with the long id - and you can then safely script away using
lockmessages as in the above script? That is this "problem" - basically an
IDE problem, and if you properly script your own application - Transcript
wont goof up on you?
More information about the use-livecode
mailing list