Using more than one stack

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
JoyceNub
Posts: 2
Joined: Sun Feb 02, 2020 12:47 am

Using more than one stack

Post by JoyceNub » Sun Jun 04, 2023 3:35 am

I used the script from my main stack to open another stack, and then close it. How do I get the rest of the script to go back to using the main stack?

JoyceNub
Posts: 2
Joined: Sun Feb 02, 2020 12:47 am

Re: Using more than one stack

Post by JoyceNub » Sun Jun 04, 2023 3:55 am

I think I figured it out! I just had to open the original stack.

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

Re: Using more than one stack

Post by dunbarx » Sun Jun 04, 2023 3:58 am

Hi.

Welcome to the forum.

When you go to another stack and then close that stack in the same handler, you will automatically find yourself back in the original stack. Something like:

Code: Select all

on mouseUp
go stack "yourOtherStack"
close stack "yourOtherStack
end mouseup
So where do you end up when you do that?

Craig

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

Re: Using more than one stack

Post by dunbarx » Sun Jun 04, 2023 4:03 am

Hi again,

It just occurred to me, do you navigate to other stacks in your sojourns? if so, you will end up in the last stack you visited.

True?

If so, just explicitly navigate to where you want to end up:

Code: Select all

on mouseUp
  go stack "otherStack1"
  wait 20 --just to see what is going on
  go stack "otherStack2'
  wait 20 --just to see what is going on
  close stack "otherStack1"
  wait 20 --just to see what is going on
  go stack "yourStartingStack" --back to the starting stack
end moueUp
Craig

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

Re: Using more than one stack

Post by richmond62 » Sun Jun 04, 2023 8:31 am

What I wonder is why you would not have ALL the stacks you need set up as substacks of a master stack;
it would certainly prove simpler.

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

Re: Using more than one stack

Post by stam » Sun Jun 04, 2023 1:12 pm

The common scenario where this will be needed is a splash stack - a stack which is loaded at startup and which will become the actual standalone app that then launches the mainstack (which remains a modifiable, normal LC stack) and closes itself.
I'd agree with Richmond that for almost everything else, substacks (for UI or code) and scriptOnlyStacks (for code, but which can also generate UI) are usually a better fit.

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

Re: Using more than one stack

Post by dunbarx » Sun Jun 04, 2023 4:31 pm

I may have simply missed what everyone seems to think is obvious, but there was no mention of a standalone.

@Joyce. Standalone? If so, substacks and a splash stack for sure.

Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”