119: Automating Tasks with Procedures

Previous: 118: Temporarily Hiding One or More Fields

Right out of the box, Panorama is a very flexible program. Its built in menus and tools bring incredible power to your fingertips. Even better, you can easily create your own commands that can be activated with a menu or button. You can create these commands (called procedures) using Panorama’s built in programming language or simply by recording each step with the built in recorder, as I’ll show you now.

#### Creating a New Procedure

The first step is to create a new procedure by choosing View>New Procedure.

If your screen is big enough, reposition the new procedure window so that it is side by side with the main database window. That way you can watch as the recording is made. The recorder works in any Procedure Editor window. When you click on the recorder tool, it turns red to show that the recorder is running.

Once the recorder is running, simply go to the main database window and perform the actions you want to record. If the procedure window is visible, you’ll see each line of code appear as each step is recorded. New steps are always added at the end of the procedure (even if you’ve been editing the code at some other spot). I’ll make a recording with two steps: 1) sorting the database by city, and 2) selecting only records in California

That’s all there is to it! When you’re done, click the recorder tool again to stop the recording (it will also stop if you close the window, or if you click on the recorder tool in another procedure editor window.) To learn more about recording, see Procedure Recorder.

To use the recording later, make sure the database window is active, then choose the procedure from the Action menu. Panorama will automatically replay all of the steps in the procedure.

To give the procedure a better name, open the procedure’s property inspector and type in a new name. The Action menu immediately upates to show the new name.

By the way, you can also run a procedure directly from its window – simply press the Run tool.

When you’re done editing a procedure, you can close it. Even if it is closed, a procedure can still be triggered from the Action menu. If you ever need to re-open it again, use the View Menu. See Procedure Editor to learn about editing code in a procedure.

#### Creating a Second Procedure

Next I’ll create a second procedure and call it West Coast Phone List.

This procedure will be a bit more complicated:

- Select people in California, Oregon and Washington
- Sort by first and last name.
- Hide all fields except for the name and phone number.

Now the Action menu has two procedures in it.

Simply select either procedure from the menu to run it.

#### Changing the Order of Items in the Action Menu

If you want to change the order of the items in the Action menu, simply choose View>View Organizer, then drag to arrange the items any way you want.

You can also make other customizations of the Action menu, see Action Menu for details.

#### Writing Code from Scratch

In addition to creating procedures with the recorder, you can also create them from scratch. To demonstrate this, I’ll create a simple procedure that displays a map of the current address. This is easy to do because Panorama has a built-in command to display a map.

Once again, the first step is to use the View menu to create the procedure.

Panorama has hundreds of commands that can be used in a procedure — in fact, it has a complete programming language. You’ll probably never memorize all of the commands that are available – in fact, even the programmers here at ProVUE haven’t memorized them all. Fortunately there’s no need to memorize them – you can simply look them up when needed. To find out how to display a map, simply open the Help wizard and search for map.

I can copy and paste from the Help wizard into my code, or simply drag and drop the sample code from the Help wizard.

Now I simply edit the code with the actual field names from the database.

For this demo, I’m going to make one further change that you wouldn’t normally use. The sample data in this data isn’t real, the street addresses aren’t valid. Since I don’t want to display a map that says location not found, I’ll change change the code to use a blank street address, so that the map will display the city.

Once the code is complete I can press the Run tool or activate the code from the Action menu.

To learn more about programming and writing code, see Code.

Next: 120: Extra Credit: Running Code Automatically

See Also

- Action Menu -- simple way to create your own menu items.
- Code -- basics of programming code.
- openmapwindow -- opens a window displaying a map of a location.
- Procedure Editor -- editing named procedures.
- Procedure Recorder -- recording database actions as code.
- Procedures -- basics of procedures for automation.

History

Version | Status | Notes
10.0 | Updated | Carried over from Panorama 6.0, with updates.