Procedures are pre-stored command sequences. They are the scripts that are executing when your application is running. One might say that proc- edures are the application as all of the other elements of an application are triggered by procedures.
For example, reports are invoked via the REPORT command, screens are invoked via the APPEND, UPDATE, READ, LOOK, or SCROLL commands, menus are invoked via the MENU command, dialogs are invoked via the DIALOG command, prompts are caused by the PROMPT command, flow of control is done with IF and GOTO commands, and so on.
The APPLICATION Procedure
There is a very important procedure that you must name APPLICATION. It is your startup procedure, the procedure that executes when the data base is opened from the File Menu or invoked by double-clicking an application icon on your desktop.
The purpose of the APPLICATION procedure is to establish any setup that you wish and to transfer control to your top-of-the-line Menu (a pulldown menu also named APPLICATION). The rest of your application initiates from that Menu. You do not want your end user to see DCL (command mode). You want the first point of control to be the APPLICATION Menu. So the last line of your APPLICATION procedure looks like this:
MENU APPLICATION
The procedure named APPLICATION is what we look for when the data base is opened from the File Menu or from an icon on the desktop. If the proc- edure named APPLICATION does not exist your users will find themselves in DCL and not know what to do next.
To see an example of an APPLICATION procedure, look in the EXAMPLE data base.
How are Procedures Invoked?
If you are in DCL execute a procedure simply by typing its name. One procedure calls another procedure by using its name as a command. A procedure is associated to a button or to a menu command line by typing its name in the properties box associated with the button or menu line. When the button is pressed, or the menu line clicked, the procedure is executed.
In your application, all procedures (except for the procedure named APPLICATION that was discussed above) are executed when the user makes a menu selection, presses a button, or certain events occur during screen processing. For more information about "certain events during screen processing" see Special Procedures
.
How are Procedures Created?
Go to the Editor and key it in. For more information about how to get to the Editor, see creating procedures
. The basic syntax rule for procedures is one statement per line and no period at the end of any statement.
By one statement per line we mean do not put two commands on the same line. You may, however, take more than one line for any single command. To do that, use the hyphen as a continuation character. For example
find -
a - is the same as:
where - find a where city=metropolis
city=metropolis
Without the hyphens we will not interpret the intended action of a multi line command correctly.
The hyphen allows continuation within a word so continuing between words requires either a space before the hyphen or indenting the next line so we don't jam it together and try to make one word out of it.