Somewhere after July 11, 2025 something changed.
I have a database that I open, and with a procedure add a record. I then fill in data into 4 or 5 fields. On adding the record automatically, the procedure also fills in Date and time. Then I quit the database with an “Apple Q”.
I am not prompted as to save or not. Actually, I often I’ve added two new records.
I have used this database for years without such an issue until last month. I only discovered it when I was trying to download data. It was like “What the Hades happened to my data?”.
I replicated this today while being conscious of looking for the results.
What gives?
Panorama uses Apple’s NSDocument class to manage opening and saving databases. This is the same class used by all of Apple’s document based applications, for example Pages, Numbers, Keynote etc. Most 3rd party document based apps also use NSDocument. By using NSDocument, this guarantees that Panorama handles documents in the standard way, so that it works exactly like all of the other document based apps on the system.
NSDocument ties auto-save to operations that are undo-able. When you perform an operation that can be undone, the system knows that the document is now “dirty” and needs to be saved at some point. If you haven’t performed any undo-able operations, the system thinks the document is “clean” and doesn’t need to be saved.
Any time you manually change a document, that change is undo-able so the document becomes dirty. Undo-able operations include adding or deleting records, editing data cells, adding or removing fields, sorting, selecting - any change you make manually can be undone. So any change you make manually will cause auto-save to kick in.
Changes made with a procedure, however, are not automatically undo-able. If you use the addrecord statement to add a record, that cannot be undone, so auto-save doesn’t kick in. (It will, however, kick in if you make any manual change to the database.)
If you open a database, then run a procedure that modifies the database, then close the database - NSDocument will not realize that the database has been modified so the change won’t be saved. There are three possible solutions: 1) Explicitly save the database (press Command-S), 2) Make some other manual modification to the database, or 3) Modify the procedure to make it undo-able.
To modify a procedure so that it’s undo-able, you need to add the startdatabasechange statement to the procedure. Here’s an example:
startdatabasechange "AllRecords","Add New Record"
addrecord
Date = today()
Time = now()
If you run this procedure you’ll see a new record has been added to the database with the date and time. But if you look in the Edit menu you’ll also see there is an Undo Add New Record menu item. In addition, the database is now “dirty”, so that if you close it, the change will be saved, even if you haven’t made any other changes.
You may wonder why all procedures aren’t undo-able. The problem is that a procedure can do anything, and it’s not possible to automatically add the correct code make any arbitrary procedure undo-able. That’s something that you, as the procedure author, has to do yourself. For example, suppose that your procedure first opened the database and then added the record. The startdatabasechange statement has to be placed after the opendatabase statement but before the code that modifies the database.
opendatabase "Invoices"
startdatabasechange "AllRecords","Add New Invoice"
addrecord
Date = today()
Time = now()
Or, suppose the code didn’t add a record, but only changed the current record. Then a different startdatabasechange option must be used.
startdatabasechange "CurrentRecord","Date & Time"
Date = today()
Time = now()
To learn more about setting up Undo-able procedures, see:
I’m a bit confused by this sentence. Did you fill in the data manually? If so, that should have caused the database to be “dirty”, so that auto-save would kick in.
You will only get a prompt if you have enabled the Ask to keep changes when closing documents option in the Desktop & Dock section of System Settings. If this option is turned off the system will just save the changes without asking. Note that this is a system wide setting - you cannot enable this independently for just Panorama.
Thank Jim,
I manually add data to the new record. This has worked for years until last month in this database.
The date and time are procedurally inputed but there are 3 fields that I key in data and an additional field that I click a button and depending on the button I click data is put in.
It will be a choice of “Machine A” or “Machine B”, depending on which button I click.
There’s something else going on that you are not telling us (probably because you aren’t aware of it).
What happens if you open a database, manually add a record and then quit. Does it prompt you in that case? If not, you need to check your System Settings.
If I open the database from a procedure or from Open Recent Databases and then go to data sheet and add a record, either if I then go to a form and edit or if I simply just quit without entering anything I am prompted as to whether I want to save changes.
This all occurred a little over a month ago and was unbeknownst to me until I wanted to export some data.
Thanks Jim.
Ok, good, that means your system settings are set up correctly.
I tried to duplicate the situation you are describing. I created a procedure that adds a record and sets the date. Then I saved and closed the database.
To test this, I:
- Opened the database
- Next, I ran the procedure. I noted that at this point, the red dot in the upper left hand corner of the window was empty. This indicates that the system doesn’t know that the database has been modified.
- Next, I edited one field in the newly created record. As soon as I press Enter or Tab, the red dot gets a black dot inside it, indicating that the database has now been modified.
- Finally, I closed the database (clicked on the close box or press Command-W). I was prompted to confirm that I wanted to save the database.
Just to double check, I also tried Quitting Panorama. In this case, I was also prompted to confirm whether to save or not.
However, if I don’t edit a cell in the record after running the procedure, I am NOT prompted to confirm.
As a final test, I added a startdatabasechange statement to my procedure. Once I did that, I would be prompted to confirm when closing or quitting after running the procedure, even if I don’t edit another cell.
George, Panorama works as I described earlier. I don’t know what you are doing, but apparently when you say you “edit it” you must mean something different that what I mean by “edit it”. In any case, I suggest that you add the startdatabasechange statement, then it won’t matter one way or the other.
By edit I mean that I enter data into the new record, in several different fields.
I will add your recommended lines of code and be done with this.
For giggles I am going to retrieve through time machine a version that is a couple of months old and see what happens.
Thanks for your help.
For the record Mac Studio, Apple M1 Max, OS 15.6 (24G84).
George
I have narrowed the cause of the issue.
In the same database with the “issue”, in the Text Editor Options, if only the Pop Up Editing is checked, the issue remains that I can put in data, quit, and not be prompted to save or not.
If I check additionally the Focus Ring option the problem persists.
If I uncheck the Popup Editing option but let stay the Focus Ring option THE ISSUE GOES AWAY.
This likely started after some upgrade of Mac OS or Panorama Update.
I have not tried other combinations of Text Editor Options but these option choices somewhat confuse me. But that is for another Post.
Thank you for persevering with this. I would have never found this because I never use the Pop-up Editing option - it is an option for compatibility with early versions of Panorama. If I was writing Panorama from scratch today I would never include this non-standard editing option.
So, it turns out you have found a bug in Panorama. If you are using Pop Up Editing, Undo doesn’t work. You can easily see this - try editing a cell with pop-up editing, then look in the Edit menu, it won’t show an option to undo your edit. But if you use the regular editing option, you’ll see Undo Typing after you edit a cell. Apparently in ten years no one has noticed this before.
Thanks Jim. That nod from you for my stubbornness is much appreciated. This whole subject of Text Edit options I find very confusing and will be posing a question after I sort out if the Pop Up Editing option is the genesis of some of my frustration.