Source language: Translate to:

Prevent Pub from shutting down

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Postby Sam Cox » Wed Mar 14, 2007 5:22 am

What are you trying to accomplish? If you want to make sure your program has "cleaned up its act" before shutting down, put your "clean up" code in Book Properties > Actions > Shutdown. The Shutdown code runs in all cases when the program terminates -- executing Neobook's Exit command, clicking the Close button on the application's window, clicking End Task in the Task Manager, and when Windows is shutting down. Only when the program hangs or crashes does the Shutown code fail to run.

It is easy to see this in action. Write a simple pub with these features:

1) a pushbutton with one line of code
Code: Select all
Exit "" ""

2) the following code in Book Properties > Actions > Shutdown
Code: Select all
Alertbox "DEBUG" "Shutting down"

Compile the program and test it in these ways:

a) click the pushbutton
b) click the applications close button (upper right corner)
c) use End Task in Task Manager
d) shutdown windows

In each case, you should see the "Shutting down" alertbox.

For your production prorgam, replace the Alertbox statement in Book Properties > Actions > Shutdown with your "clean up" code.

-- Sam
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

Postby Sam Cox » Wed Mar 14, 2007 10:06 am

1) Under what circumstances is the alertbox appearing twice? It appears only once for me.

2) I do not know of a way to guarantee that the shutdown code will run. In fact, there is one situation -- pulling the power cord -- that will suddenly stop the computer so that the shutdown code cannot possibly run.

3) In another thread, someone talked about using a "watchdog" program that runs in the background and monitors the main pub. If the watchdog detects that the main pub has stopped running, it takes whatever action is needed to clean up after the main pub. A watchdog program is not easy to write (although HPW has plugins that will help), and there is STILL no guarantee that a user cannot get around it.

It sounds like you are trying to protect files. What kind of files? A technique that might work for you is to arrange for the files to be useable only by your program by encoding them in a unique manner.

At one time, Alberto Meyer of TechMedia Software published his tmStorage plugin that allowed you to extract and use files without ever writing them to disk. I don't know if that plugin is still available.

Hope this helps,
-- Sam
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

Postby Sam Cox » Wed Mar 14, 2007 8:33 pm

The registry utilities -- RegistryRead and RegistyWrite -- are documented in the help file. Neobook's registry utilities provide for reading and writing string values but not other types of registry values. If Neobook's registry functions aren't powerful enough for you, you can always use .reg files. Google "reg files" to learn more.

Please heed this note from Neobook's help file:

WARNING: Exercise caution when modifying the Registry. If there is an error in the Registry, your computer (or your reader’s computer) may become nonfunctional.
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 2 guests