cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Craige_Hales
Super User
FileSnapper

@mlrpadilla asked about recovering files when JMP does not get a chance to save them. How do I recover most recent work on JMP files in cases of unavoidable computer/JMP shutdown? 

I had a similar experience a year ago, with .JSL scripts, when a power failure cost me several hours of work. I wrote an add-in to periodically look for open JSL files and make snapshots of them. It does not snapshot JMP data tables. And it only works on Windows. But it has saved my JSL for me a couple of times since. It has also failed me at least once (below.)

FileSnapper Add-in

After installing, the FileSnapper add-in script runs every five minutes (default) and looks at the open windows to find script windows that have been modified. When it finds one, it grabs the text and saves it away. 

If JMP does not get a chance to close normally, a sentinel file is left behind. The next time JMP launches and finds the sentinel, JMP will open the FileSnapper dialog to let you see if there is a snapshot you want to restore. You can also open the dialog from the add-ins menu and set a few properties (like the 5-minute interval and the 14-day retention period.)

How it works

To keep FileSnapper as invisible as possible, it does not use the JSL scheduler. (The scheduler opens a window, and there is only one scheduler that you might want to use for something else.) Instead, FileSnapper uses RunProgram to get a periodic wake-up call. There were a number of iterations; the current version is using CMD.EXE and the DOS waitfor command in a loop to send some text back to FileSnapper every five minutes. When JMP shuts down, it signals the waitfor event to make CMD.EXE exit quickly. CMD.EXE will also terminate if the sentinel disappears.

A tiny JMP data table is used for the sentinel file. The table is saved, but also kept open as a private table. If a second copy of JMP runs, it detects the table is open in another copy of JMP and (1) does not open the recovery dialog and (2) makes a different sentinel file. If any non-open sentinel is found, all the non-open sentinels are removed and the recovery dialog is opened. You should only get prompted once for recovering files.

The add-in uses the shutdown hook to remove the sentinel and do several things to make sure RunProgram terminates. There may be a few diagnostic show() calls left behind, but you can't normally see their output because JMP is shutting down. You can use the view->add-ins to enable/disable FileSnapper and watch them in the log window.

The backup() function is called from RunProgram every five minutes. Backup() looks for editor windows that are dirty (modified), compares their content to the last time, and if changed saves a copy. A special folder is created under Documents for the snapshots. The files are marked read only to help you not try to use them because...

Every time FileSnapper starts up, it studies the old snapshot files. FileSnapper quietly deletes old snapshots. You can control how noisy the log is, but you don't want to make FileSnapper log every snapshot it makes because you may lose a keystroke or two every five minutes, and more log activity just makes it worse.

The dialog window (after a failure, or from the menu) shows a list of most-recent to oldest snapshots. You can (1) double click to open, or (2) single click to select. If you select one file you can right-click the selected file (right-click does NOT select, bummer!) and compare to an existing file. if you select two files, you can right-click and compare the two. Check the title of the compare window to quickly see if the files are the same. Compare to an existing file does not prompt; it looks in the registry and some identified directories for a file of the right name. It may or may not be the file you want to compare to.

But I still lost some work.

When you are developing a script, you'll often press escape to stop the script. FileSnapper is a script. There appears to be no way to prevent it from occasionally processing the escape key and stopping at just the wrong time, never to run again five minutes later. There is a half-baked idea in FileSnapper to make a report that it stopped, but only if a data table is opened after five minutes later. In my case, I don't use data tables that often when I'm writing scripts, so I might not get the notice.

At one point I set the retention to 100 days and the snapshot frequency to 30 seconds. This is too much. There were over 10,000 files and JMP startup could take 30 seconds. Choose your pain level in the dialog's options. Press the save button, then close the dialog.

I'd wish for this to be built in to JMP, and I'd wish for better callback timers. There are a lot of improvements that could be made (like the save button in the dialog does not give any feed back). It might or might not actually help someone. If you get tired of the occasional missed keystroke, you can uninstall it. The same view->add-ins menu will also let you look at the source. Thanks to @Justin_Chilton for pointing out how the JSL windows in a project work.

 

Add-in.

 

Last Modified: Oct 14, 2020 10:33 PM
Comments