How to properly exit program

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
asawyer13
Posts: 53
Joined: Sun Jun 24, 2007 4:47 pm

How to properly exit program

Post by asawyer13 » Wed Jun 05, 2013 6:43 pm

I have written a small LC program for Windows that is essentially meant to start, do some work, then exit.

When I compile it to standalone, I can't seem to get it to exit. It stays running in memory.

I've tried everything I can think of but obviously am missing something.

Also should I run my code all in the On Startup?? or on a preopen??? I'm a bit confused when the various Card and Stack events fire.

For example, I am running everything in On Startup, and part of what I'm doing is geocoding an address via http, but it doesn't seem to work when compiled, but works fine if I step thru the Card via debugger.

Thanks for any help. Feel free to point me to other places that will help me learn. I did look at the Dictionary, but it seems mostly helpful when you know what you're looking for. I have Commercial license.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to properly exit program

Post by Klaus » Wed Jun 05, 2013 6:49 pm

Hi,

Sounds like you do not need a visual representation of your stack at all, right?
In that case I would do something like this:

Code: Select all

on preopenstack

  ## So the user will not see anything on screen
  set the visible of this stack to false
end preopenstack

on openstack
  ## do your stuff here...
  ## More stuff to do here...

  ## Done? Then:
  quit  ## :-)
end openstack
Not tested, but sounds like this will work :-)

Best

Klaus

asawyer13
Posts: 53
Joined: Sun Jun 24, 2007 4:47 pm

Re: How to properly exit program

Post by asawyer13 » Wed Jun 05, 2013 6:52 pm

Klaus,
I will try this tonight and let you know how it works.

Thanks

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: How to properly exit program

Post by jacque » Wed Jun 05, 2013 7:22 pm

Libraries do not load on startup, so the internet library you're using won't be available until after the card opens. That's why it isn't working in your standalone. In the IDE, the libraries are all loaded already by the time it opens your stack.

Apps will remain in memory if there is any process still open -- that can be a driver or any pending messages or actions. Make sure that anything a script has started is actually stopped before the app quits. Check if you have any pending messages in the queue or if the http call is waiting for a response.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

asawyer13
Posts: 53
Joined: Sun Jun 24, 2007 4:47 pm

Re: How to properly exit program

Post by asawyer13 » Wed Jun 05, 2013 8:34 pm

Jacque
Makes perfect sense and explains what I'm seeing.
I will make changes tonight.
Lots to learn but love being here.

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: How to properly exit program

Post by bangkok » Wed Jun 05, 2013 10:07 pm

To quit properly, look at the script written by Mark :

http://forums.runrev.com/viewtopic.php?t=1026

asawyer13
Posts: 53
Joined: Sun Jun 24, 2007 4:47 pm

Re: How to properly exit program

Post by asawyer13 » Thu Jun 06, 2013 1:04 am

Thanks everyone. My program is now working and exiting also.

Cool

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: How to properly exit program

Post by jacque » Thu Jun 06, 2013 5:47 am

Just out of curiosity, what was it?
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

asawyer13
Posts: 53
Joined: Sun Jun 24, 2007 4:47 pm

Re: How to properly exit program

Post by asawyer13 » Thu Jun 06, 2013 9:59 am

I ended up using the code from Klaus, running my stuff at "on openstack" and then quitting. It's a simple program, I made sure I closed the database, etc, first.
Thanks again everyone.

Post Reply