Page 1 of 1
Nonexistent topStack
Posted: Thu Jan 18, 2024 12:16 pm
by richmond62
I am having a problem with a button on a stack called "Nonsense":
Code: Select all
on mouseUp
palette "Nonsense"
put the short name of the topStack into STAKK
if STAKK is empty then
put "Utter Cack!"
else
put STAKK
end if
wait 5 seconds
topLevel "Nonsense"
end mouseUp
What I do NOT understand is why, when there is NO topStack I do not get 'Utter Cack' in the messageBox.
Re: Nonexistent topStack
Posted: Thu Jan 18, 2024 2:40 pm
by stam
2 comments:
1. to see the text in the message box immediately on click, use 'wait with messages' as this allows the interface to update - otherwise the text appears after the 5 seconds have elapsed
2. The topStack is
never empty - if no topStack is open, it defaults to revMenuBar (or if the script editor is open, it uses that instead).
You can test the the above with slight modifications to your script:
Code: Select all
on mouseUp
local STAKK
palette "Nonsense"
put the short name of the topStack into STAKK
if STAKK is empty or STAKK begins with "rev" then
put "Utter Cack!"
else
put STAKK
end if
wait 5 seconds with messages
topLevel "Nonsense"
end mouseUp
Re: Nonexistent topStack
Posted: Thu Jan 18, 2024 5:04 pm
by richmond62
Thank you: I'll check that tomorrow.
Re: Nonexistent topStack
Posted: Sun Jan 21, 2024 2:02 am
by dunbarx
All.
However this thread plays out, I was surprised to learn that a palette is not, apparently, a "stack", in that after one "palettizes" it, LC no longer "sees" it as one:
Code: Select all
answer the stacks
answer the topStack
The "stacks" does not include it, and the "topStack" return the revMenuBar. When one restores its status by:
it comes back into the fold.
Craig
Re: Nonexistent topStack
Posted: Sun Jan 21, 2024 2:06 am
by dunbarx
What I mean is, if palletizing a stack takes away its stack "property", what sort of object does it become? And then how does such an object become a stack at all?
Craig
Re: Nonexistent topStack
Posted: Sun Jan 21, 2024 3:57 am
by stam
Maybe I'm misunderstand your posts Craig?
Not sure a palette loses its 'stack' property, as you can still reference the palette with its stack name.
And the keyword
the stacks returns file references to all stacks, including palettes - for example, the following are included when I type
put the stacks in the message box:
Put the stacks wrote:/Applications/LiveCode 10.0.0 (dp 7).app/Contents/Tools/Toolset/palettes/message-box/revmessagebox.8.rev
/Users/stam/Downloads/nonsense.livecode
/Applications/LiveCode 10.0.0 (dp 7).app/Contents/Tools/Toolset/palettes/menubar/revmenubar.livecodescript
/Applications/LiveCode 10.0.0 (dp 7).app/Contents/Tools/Toolset/palettes/inspector/revinspector.livecodescript
Where the stack 'nonsense.livecode' is a stack I use for testing purposes and turned into a palette
and saved it.
Keep in mind that new and unsaved stacks appear as blank lines because they don't have a filename.
The Dictionary on 'The Stacks' wrote:Since unsaved stacks have no file name, the file names of unsaved stacks are not included in the list. Instead, each unsaved stack is represented by a blank line in the list.
The file paths of substacks are included, but the stack names themselves are not. This means that if more than one stack in a file is open, that file's path appears more than once in the list returned by the stacks function.