Quit an app

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
D4vidrim
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 61
Joined: Fri May 31, 2013 9:32 am

Quit an app

Post by D4vidrim » Sun May 25, 2014 8:37 pm

Hi!
New basic question:
I have a main stack and a substack and I want the app to quit if I clic on the X of the main stack and to just close the substack if I clic on its X.

If I put his code on the main stack:
on closeStack
quit
end closeStack

and this code on the other substacks:
on closeStack
end closeStack

it works fine, but I was wondering if there is a better way to reach the same goal!

Thank you, Davide

sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: Quit an app

Post by sefrojones » Sun May 25, 2014 9:02 pm

Would something like this work? Just put it into the main stack script, and i think it will do what you're asking.

Code: Select all

on closestackrequest
   put the owner of the target into tStackTitle
   set the itemdelimiter to space
   delete item 1 of tStackTitle
   replace quote with empty in tStackTitle
   if tStackTitle is "MyMainStack" then
      quit
   else
      close stack tStackTitle
   end if
end closestackrequest


Not sure if that's the best way to go about it, but maybe it's what you're looking for.


edit: removed the line that replaced space with empty, as this would mess things up if there was a space in your stack titles

sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: Quit an app

Post by sefrojones » Sun May 25, 2014 9:33 pm

As a matter of fact, maybe this one is a little better.

Code: Select all

on closestackrequest
   put the short name of the owner of the target into tStackTitle
   if tStackTitle is "MyMainStack" then
   quit
   else
      close stack tStackTitle
      end if
end closestackrequest

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Quit an app

Post by atout66 » Mon May 26, 2014 7:16 am

Hi to all,
I want to thank you sefrojonesGAda40, because I had the same question than D4vidrim and your last example is exactly what I needed :wink:
Great forum !

Cheers, Jean-Paul.
Discovering LiveCode Community 6.5.2.

D4vidrim
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 61
Joined: Fri May 31, 2013 9:32 am

Re: Quit an app

Post by D4vidrim » Mon May 26, 2014 9:46 am

it works very well, thanks!

Post Reply