Panorama X does not recognize some database changes


#1

I am very happy that Panorama X supports the OS X Versioning. I am wondering if other OS X features like Autosave and Reopening windows (that were open when I quit Panorama X) are supported. The last option does not seem to be supported; with the first option (Autosave) I am getting mixed results.

I would agree with not using autosave, but when I quit Panorama X, Panorama should ask if I want to save unsaved modifications. Otherwise I am going to lose my changes. I just watched such a case and was surprised to see that my database reopened in its previous state.

My tests show that my little test database does not seem to know that it has been edited when the I only replace its data completely with a procedure (using the importtext statement with the option “Existing data”, “Replace”). There is no notification in the window title bar, no “— Edited” appended. When I quit Panorama now, the changes are not saved, and Panorama does not ask me.

It’s different when I edit a record: Then “— Edited” gets appended to the database name. When I close the window now (with the red button in the title bar), Panorama X asks me if I want to save or to revert the changes – the expected behavior. When I use the Quit command instead (without saving before), Panorama does not ask me to save or revert, but it seems to autosave my database.


#2

In fact, Panorama X databases only take notice of changes when the user edits data in cells in the spreadsheet.

  • If data are replaced via procedure, the database still thinks it is unchanged.

  • If the user makes modifications in procedures, the database still does not recognize it is edited.

All these cases can cause data (or procedure) loss, because Panorama X would let the user quit the application without warning and without saving the changes.


#3

Panorama X supports AutoSave, it does not support reopening windows.

AutoSave is supported using Apple’s code, which uses the Undo mechanism to determine whether or not the database needs to be autosaved. When an operation that can be undone is performed, Apple’s code knows that autosave is necessary. If an undoable operation has not been performed, it won’t know to auto-save.

Normally, procedures aren’t undo-able, so they don’t trigger auto-save. To make a procedure undo-able, you need to add a startdatabasechange statement at the top of the procedure. The startdatabasechange help page describes this pretty well, and there is also a short (13 minute) free video on the Panorama X video on demand page that shows how to do this (video #19).

Suppose you had a simple procedure like this:

Name="Bob"

To make this undo-able (and also make it work with auto-save), you have to modify this procedure like this:

startdatabasechange "CurrentRecord","Name is Bob"
Name="Bob"

When you run this procedure, the Edit menu will contain Undo Name is Bob, and the database will be automatically saved if you close or quit.

I’m sure many of you reading about this for the first time will wonder why this is necessary – why doesn’t Panorama do this for you automatically. That would be nice, but it is simply impossible. To do that, Panorama would have to somehow analyze the procedure and automatically figure out whether or not the database is modified, and if so, what type of modification (a single record, all records, field configuration, etc.) This has to happen before any changes are made – it can’t be done after the fact. It’s just not possible, so you have to make this slight modification to your procedures (or, you could add a save statement at the end of your procedure.

Note: in some cases this statement would not go at the very top. For example, you might have a procedure that asks the user if they want to do something, then proceeds only if they press OK or provide a certain value. In that case, you should not use the startdatabasechange statement until right before the code actually makes the change. If the user presses Cancel, you don’t want any Undo.

This is a known bug that I have not tracked down yet. So for now, you have to make sure to save after you make modifications to procedures.

https://bitbucket.org/jimrea/panoramax/issues/208/editing-procedure-does-not-dirty-database


#4

Normally, procedures aren’t undo-able, so they don’t trigger auto-save. To make a procedure undo-able, you need to add a startdatabasechange http://www.provue.com/panoramax/help/statement_startdbchange.html statement at the top of the procedure.

Thank you, Jim, for the explanation.

The startdatabasechange statement does the trick! The database now changes its status to „Edited“ and does the autosave when I quit Panorama X.

Kurt