Nonexistent topStack

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Nonexistent topStack

Post by richmond62 » Thu Jan 18, 2024 12:16 pm

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.

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Nonexistent topStack

Post by stam » Thu Jan 18, 2024 2:40 pm

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9388
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Nonexistent topStack

Post by richmond62 » Thu Jan 18, 2024 5:04 pm

Thank you: I'll check that tomorrow.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9670
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Nonexistent topStack

Post by dunbarx » Sun Jan 21, 2024 2:02 am

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:

Code: Select all

topLevel myStack
it comes back into the fold.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9670
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Nonexistent topStack

Post by dunbarx » Sun Jan 21, 2024 2:06 am

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

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Nonexistent topStack

Post by stam » Sun Jan 21, 2024 3:57 am

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.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”