Adding a record by procedure

Somewhere there is a command to add a new record with data to a database, not necessarily the frontmost, and I cannot remember what it is. Could someone remind me?

This would be a good item to put in the See Also list for addrecord and associated topics.

Check out pasterecord. Also insertrecord and insertbelow. They’re on the See Also list of addrecord.

The post statement allows you to add a new record to another database and propagate it with data. This statement is not listed in the See Also section of the addrecord statement.

Thank you!

When this question was originally posted, I didn’t even think of the post statement (see what I did there?). Thanks Gary! I have changed the documentation so that post is listed in the See Also section for the addrecord statement.

For the past 25 years, I have been keeping my income records in a database opened secret behind my customer contacts. When I needed to enter a payment, I would open the data sheet in the income file and enter it. Closing the sheet would save the file and make it secret again, rather than closing the file.

Panorama X does not do this, so I want to post the data without opening the data sheet of the income file. I want to be able to do everything from the contacts file, so post is the statement to use. I suspect this will become more important for others besides me.

It is a trade-off. I now have a list in the contacts file that shows the transaction history, which is nice, but it is not as simple for a one-man operation like I have been. I will need to be able to modify records to mark when I have actually been paid, but that is another statement that I should be able to hunt down. Again, something that will be useful for others.

When I get all this done, I should have a fairly professional-looking system, probably just about the time I get too old to work any longer!

There must be more to the story, because Panorama 6 will also normally close the file if you click on the close box. You must have done something special to your file to make this happen, I have a couple of ideas as to what you may have done.

Back in the Panorama II days, there was no “secret” window feature, so the Power Team databases would simulate this by opening a small form window off the edge of the screen, so it was invisible. Perhaps you are using a method like this – it would work the way you describe, and if you have been doing this for 25 years, that would take you back into the Panorama II era.

Another way this could be done starting with Panorama 4 would be by creating a .CloseDatabase procedure and putting in a closewindowkeepsecret statement if there is only one window open for this database. Panorama X does not support the . CloseDatabase procedure, so this won’t work in Panorama X. But this is definitely not a standard feature of Panorama 6. If this is what you did, I congratulate you on reading the Panorama 6 documentation closely, as this is only mentioned in passing on page 398 of the Panorama 6 Formulas & Programming book.

The way Apple’s API’s handle documents do not allow for something like a .CloseDatabase procedure, so this won’t be added to Panorama X. It is possible, however, than an database option could be created to prevent a database from ever closing – making it secret if you try to close it. This is already done for Panorama’s library databases. I’ve created a BitBucket entry for this idea. Of course if a database had this option set, you could not ever close it except for quitting Panorama, or turning off the option.

In the meantime, you could make a menu command that runs the makesecret statement, but you would have to be careful to close the window with this menu command, and not the close box.

Also, there is nothing magical about the post statement – you could write your own code to switch to the secret window and perform any operation you want, for example to mark when you have been paid. You can look at the source code of the post statement for inspiration. In fact, I didn’t write the post statement – I think it was Dave Thompson. If I am misremembering that my apologies to the actual author. But the point is that it uses standard code that is available to anyone, the post statement simply makes this job a bit easier if you learn it.

I had a .CloseWindow procedure:

LastRecord
If info(“Files”) CONTAINS “Addresses”
If info(“Changes”) ≠ 0
Save
Endif
MakeSecret
Else
CloseWindow
Endif

Which did what I wanted when I clicked the close button.

What I have in Panorama X is a .CurrentRecord procedure which reopens the Income file secretly if it has been closed. It does not update the record which is showing, but it either does not matter, or it has been updated before the file is closed. I cannot remember which.

Yes, .CloseWindow is not supported either. OS X simply doesn’t support the ability to perform multi-step actions like this as the window is closed.

Panorama allows extreme customization of how the user interface works. This is true of Panorama X and was true of Panorama 6 and earlier versions also. I don’t know if there is any other program on the Mac that allows this level of customization. Many of the advanced customization options are very tightly integrated into operating system behavior. From OS X to macOS 10.14, the Mac has really contained two operating systems in one - the modern system derived from the NeXT computer (called Cocoa), and the older system derived from the original MacOS (called Carbon). Although these two operating systems are connected in some ways, they really are separate. Panorama 6 was designed to run on the Carbon operating system (which was 32 bit). Panorama X runs on Cocoa. Carbon and Cocoa are separate in many ways, and somethings that were easy in Carbon are difficult or impossible on Cocoa, so some old tricks simply can’t be performed on the new version. On the other hand, the reverse is also true, and partially because it is based on Cocoa, Panorama X can easily jump many hurdles that Panorama 6 could only dream of.

In any case, with the advent of macOS 10.15, there is now only one operating system, Cocoa. Carbon has been removed. In fact, I suspect that removing Carbon is the primary reason why 32 bit support was dropped. It must have been a nightmare for Apple engineers to support two separate operating systems for all these years. In any case, Panorama X is now jumping a hurdle that Panorama 6 will never clear – which is running at all on 10.15 and later systems. Back in 2012 when I started on Panorama X I knew this day was eventually coming, and now it is here.

In sum, the more you “tricked out” your Panorama databases with advanced customization options, the greater chance that you might run into issues converting to Panorama X. That’s unfortunately a penalty of living somewhat out on the “bleeding edge” of technology.

As you know, I have done things you did not imagine in Panorama 6 and earlier.

I am hoping that Catalina will stop crashing while editing forms brought over from Panorama 6.

My wife’s computer does not run anything newer than High Sierra, so I can always reference old databases on it, at least until it dies.

Another approach would be to have a timer running in the background to check to see if your file is still open and to load it if it is not.

starttimer "CheckSecret","code",{
    If arraysearch(info("files"),"My File",cr())=0
        opensecret "My File"
        farcall "My File", .Initialize
    Endif}

The farcall statement can be eliminated if the My File database does not have an .Initialize procedure or if the procedure does not need to be run when secretly reopening.

There are so many ways of doing things in Panorama!