The startdatabasechange statement adds undo support to a procedure.
This statement has two parameters:
modification – the type of modification that will be made by the procedure. The available types of modification are:
menutitle – the title that will be displayed in the Undo/Redo menu items. For example, if the title is Add Invoice the undo menu after the procedure will be Undo Add Invoice. If the title parameter is omitted, Panorama will use the name of the procedure the statement is in as the title.
Panorama’s built in operations are undo-able, but out-of-the-box, your procedures aren’t. You can use the startdatabasechange statement to fix that. Use this statement just before you make a database change. Here is an example that allows a procedure that creates a new invoice to be undo-able.
startdatabasechange "ALLRECORDS","Add Invoice" addrecord Date=today() Time=now() Shipping="UPS"
Note that in the example above, if the procedure itself is named Add Invoice, the second parameter could be omitted, like this.
startdatabasechange "ALLRECORDS" addrecord Date=today() Time=now() Shipping="UPS"
You only need to use the title parameter if you want the title that appears in the Undo menu to be different than the procedure name.
The startdatabasechange statement is easy to use, but you do have to make sure that you use the right option for the Modification parameter. Most of the time the correct choice is AllRecords, but if the procedure only modifies the current record you should use CurrentRecord. The other options are only used if you change the fields themselves.
Even if you make multiple changes, you should only use the startdatabasechange statement once. When multiple changes are made, choose the modification option that is most broad. For example, if the procedure modifies a field in the current record and modifies multiple records, you should use the AllRecords option.
One thing to keep in mind is that Undo is limited to one database at a time. In the procedure below, only statements up to the window statement will be undo-able.
startdatabasechange "ALLRECORDS","Some Operation" ... ... ... window "Some Other Database" ... ... ...
You could add another startdatabasechange statement after the window statement. However, this would require two Undo commands to completely undo – first you would have to use Undo in the second database, then click on the second database and Undo again. There is no way to combine this into a single undo operation.
All of these examples have shown the startdatabasechange statement as the first statement in the procedure, but sometimes you might not want that. In this example, there is nothing to undo if the user clicks on No, so the startdatabasechange statement should go after the endif statement.
alertnoyes "Are you sure you want to add an invoice?" if info("dialogtrigger") = "No" return endif startdatabasechange "ALLRECORDS","Add Invoice" addrecord ...
Make sure, however, that the startdatabasechange statement appears before you start modifying the database. Any changes made before this statement will not be undo-able.
Tip: It’s not necessary, but it may be helpful for you to understand how the startdatabasechange statement works. Basically, this statement takes a “snapshot” of the data you are about to modify. When the Undo command is used, Panorama reverts the data back to the snapshot. For example, if the CurrentRecord option is used, Panorama saves a snapshot of the current record. If the AllRecords option is used, Panorama saves a snapshot of the entire database. There is no way for you to directly access these snapshots, but they are used by the Undo and Redo commands.
|10.0||New||New in this version.|