Exit to top?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
- Posts: 10076
- Joined: Fri Feb 19, 2010 10:17 am
Re: Exit to top?
A US cultural expression.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Exit to top?
Richmond.
You really must lighten up a bit.
Jacque. I live in Manhattan, but my youth was in Texas.
Northerners look down on Southerners. Southerners do look down on Northerners, but only because Northerners look down on Southerners.
In Texas itself, those in Dallas look down on those in Houston. Why? because they say those in Houston are oil-covered cowboys. The people in Houston look down on those in Dallas, because they say they are just fancy-pants New Yorker wannabes.
Human nature, mostly, and not particularly sinister.
Craig
You really must lighten up a bit.
Jacque. I live in Manhattan, but my youth was in Texas.
Northerners look down on Southerners. Southerners do look down on Northerners, but only because Northerners look down on Southerners.

Human nature, mostly, and not particularly sinister.
Craig
Re: Exit to top?
Craig, I didn't know you grew up in Texas. My nephews are there and I love them regardless. They taught me the expression, "he's all hat and no cattle."
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Exit to top?
Sorry to interrupt this ethno-idiomatic discussion 
Here is a test stack that shows that the substack exit command does not stop the modal dialog calling script.

Here is a test stack that shows that the substack exit command does not stop the modal dialog calling script.
-
- Livecode Opensource Backer
- Posts: 10076
- Joined: Fri Feb 19, 2010 10:17 am
Re: Exit to top?
I am a bit worried (especially re Yanks) . . . almost as ridiculous a words as Brits . . . if I lighten up the cork might pop out. 

Re: Exit to top?
Wouldn't 'exit to top' in this case stop all execution in the substack and jump back to the calling stack as this is the substacks top?
Andy .... LC CLASSIC ROCKS!
-
- Livecode Opensource Backer
- Posts: 10076
- Joined: Fri Feb 19, 2010 10:17 am
Re: Exit to top?
Let's try and find out . . .
Here's a stack with a substack:
- -
The script of the button on the substack contains this:
The openCard script of the substack is this:
on clicking the button 'EXIT to Top' the repeat loop in the cardScript stops, but the substack does NOT close.
The button 'CLOSE!' has this:
On clicking that button the substack vanishes, and the button 'Open Substack' on the main stack refuses to open the substack again.
Here it is, have a play with it.
Here's a stack with a substack:
- -
The script of the button on the substack contains this:
Code: Select all
on mouseUp
exit to top
end mouseUp
Code: Select all
on openCard
put 1 into CYCLE
repeat until CYCLE > 5000
move img "ooo" to 50, 200
wait 5 ticks with messages
move img "ooo" to 350, 200
add 1 to CYCLE
end repeat
end openCard
The button 'CLOSE!' has this:
Code: Select all
on mouseUp
set the destroyStack of stack "SUBST" to true
close stack "SUBST"
end mouseUp
Here it is, have a play with it.
- Attachments
-
- MAINST.livecode.zip
- Stack.
- (2.6 KiB) Downloaded 783 times
Re: Exit to top?
Zax..
It sure seems as if the repeat loop continues. If I change the style of the stack to anything but "modal", then "exit to top" works as advertised.
Craig
It sure seems as if the repeat loop continues. If I change the style of the stack to anything but "modal", then "exit to top" works as advertised.
Craig
Re: Exit to top?
@Zax
Apologies for hijacking your topic. I haven't tested it but try adding a "start using stack <mainstack > to an openstack/opencard handler and see if that extends the message hierarchy to include the calling stack.
Apologies for hijacking your topic. I haven't tested it but try adding a "start using stack <mainstack > to an openstack/opencard handler and see if that extends the message hierarchy to include the calling stack.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Livecode Opensource Backer
- Posts: 10076
- Joined: Fri Feb 19, 2010 10:17 am
Re: Exit to top?
So, the problem lies with using a modal stack.
Re: Exit to top?
No need to apologize Jacque, you can do whatever you want (on this forum)
I just tried "start using..." but it doesn't change anything.
It looks like a bug: in my opinion, exit to top command should really stop all scripts.

I just tried "start using..." but it doesn't change anything.
It looks like a bug: in my opinion, exit to top command should really stop all scripts.
I think so. As Jacque suggested, it may be a scope issue.
Re: Exit to top?
So that was interesting... It seems that the combination of calling a modal in the middle of loop greatly restricts what what you can do.
Doing anything that modifies the calling stack raises an error because of this combination I think.
However there are some ways around this.
The "lamest" way of doing this, is just adding a line to the loop within "Click Me" button's repeat with loop:
Code: Select all
if "STOPPED" is in field "test" then exit mouseUp
A better way is to set a flag in the substack acting as modal.
While in the example below it's used to break the loop, your can use this to exit the parent handler instead or take any action depending on what the flag is set to (and/or you can set multiple flags for multiple actions).
In your simple example, the following works: in the modal's button btnExit's script, just set a flag as a custom prop of the stack:
Code: Select all
on mouseUp
set the dialogData to (the short name of me)
set the uStop of this stack to true ------ set a flag in the substack
close this stack
put " STOPPED BY FLAG" & cr after fld "Test" of stack (the mainStack of this stack)
end mouseUp
Code: Select all
on mouseup
put "" into fld "Test"
repeat with i = 1 to 10
if the uStop of stack "Dialog" then exit repeat ------ act on flag in substack
put "Iteration" && i & cr after fld "Test"
if (i = 5) then modal stack "Dialog" // see btn "Exit to top" of sub-stack "Dialog"
end repeat
end mouseup
I'm sure there must be other/better ways of doing this but this is simple and it works; and you can take any number of actions depending on the value of the flag(s) set, and as custom props these are easily accessible even if the substack has been closed.
Stam
Re: Exit to top?
One additional comment: if using a custom prop as a flag, remember to reset it to it's default value (in this example you'd need to set the uStop of stack "dialog" to false either just before stopping the loop, or preferably when acting on the flag).
In otherwords, the "click me" button's script should look something like this:
In otherwords, the "click me" button's script should look something like this:
Code: Select all
on mouseup
put "" into fld "Test"
repeat with i = 1 to 10
put "Iteration" && i & cr after fld "Test"
if (i = 5) then modal stack "Dialog"
if the uStop of stack "dialog" then
set the uStop of stack "dialog" to false
exit to top
end if
end repeat
end mouseup
Re: Exit to top?
There are several workarounds (I still believe that using the dialogData global property is the simplest).
"Exit" button script:
Code: Select all
on mouseUp
set the dialogData to (the short name of me)
close this stack
put " STOPPED BY EXIT TO TOP" & cr after fld "Test" of stack (the mainStack of this stack)
exit to top -- !!!!!!!!!!!!!
end mouseUp
Code: Select all
on mouseup
put "" into fld "Test"
repeat with i = 1 to 10
put "Iteration" && i & cr after fld "Test"
if (i = 5) then modal stack "Dialog" // see btn "Exit to top" of sub-stack "Dialog"
if ("exit" is in the dialogData) then exit to top -- !!!!!!!!!!!!!!
end repeat
end mouseup