Page 1 of 1

How to properly exit program

Posted: Wed Jun 05, 2013 6:43 pm
by asawyer13
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.

Re: How to properly exit program

Posted: Wed Jun 05, 2013 6:49 pm
by Klaus
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

Re: How to properly exit program

Posted: Wed Jun 05, 2013 6:52 pm
by asawyer13
Klaus,
I will try this tonight and let you know how it works.

Thanks

Re: How to properly exit program

Posted: Wed Jun 05, 2013 7:22 pm
by jacque
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.

Re: How to properly exit program

Posted: Wed Jun 05, 2013 8:34 pm
by asawyer13
Jacque
Makes perfect sense and explains what I'm seeing.
I will make changes tonight.
Lots to learn but love being here.

Re: How to properly exit program

Posted: Wed Jun 05, 2013 10:07 pm
by bangkok
To quit properly, look at the script written by Mark :

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

Re: How to properly exit program

Posted: Thu Jun 06, 2013 1:04 am
by asawyer13
Thanks everyone. My program is now working and exiting also.

Cool

Re: How to properly exit program

Posted: Thu Jun 06, 2013 5:47 am
by jacque
Just out of curiosity, what was it?

Re: How to properly exit program

Posted: Thu Jun 06, 2013 9:59 am
by asawyer13
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.