Page 1 of 1
Completely deleting substack / stack
Posted: Thu Apr 18, 2019 8:10 am
by shawnblc
I have a stack with a substack. On the substack I have a button and I want it to delete the substack. I believe I did this about 3 years ago. I guess I need to spend more time with LC

What am I doing wrong?
Basically I want the substack to show only once during the lifetime of the application.
On the substack I have:
Code: Select all
on mouseUp
answer "Hello"
wait 5 milliseconds
delete stack "testCard"
end mouseUp
On the main stack I have:
Code: Select all
on closeStack
save stack "mainStack"
end closeStack
Re: Completely deleting substack / stack
Posted: Thu Apr 18, 2019 8:50 am
by Klaus
Hi Shawn,
I think LC does not like to delete a stack while a script IN that stack is being executed.
Just like you cannot delete controls with/in their own script(s).
Add a handler in the MAINSTACK thaqt will delete the substack:
Code: Select all
command el_deleto
delete stack "testCard"
end el_deleto
Then just call this handler in the substack:
Code: Select all
on mouseUp
answer "Hello"
wait 5 milliseconds
del_deleto
end mouseUp
That should do the trick.
Best
Klaus
Re: Completely deleting substack / stack
Posted: Thu Apr 18, 2019 2:49 pm
by shawnblc
Thanks Klaus, but I'm still having issues.
Re: Completely deleting substack / stack
Posted: Thu Apr 18, 2019 3:05 pm
by Klaus
Hi Shawn,
you need to type a bit more careful:
Code: Select all
on elDeleto
## if there is a stack stack "testCard" then
if there is a stack "testCard" then
delete stack "testCard"
end if
...
With this script I got it working:
Code: Select all
on mouseUp
answer "hello"
wait 5 milliseconds
## No script must be running when we remove the stack!
close this stack
## we need to add a tiny dealy here, or the script is still considered running and we get an error
send "elDeleto" to stack "Test" in 1
## If eldeleto does work, this line will throw an error, since the stack is not present anymore!
## close stack "testCard" of stack "Test"
end mouseUp
Best
Klaus
Re: Completely deleting substack / stack
Posted: Thu Apr 18, 2019 4:05 pm
by shawnblc
Excellent Klaus. Got it working. Thanks.
I need to try and spend an hour or so with LC every day instead of dropping off and not using it for years at a time.

Every time I go back to LC and tinker, I'm amazed.