You are here: Commands > Do Procedure

Do

Use the Do command from the command line or in a procedure to run a procedure or a procedure label. You can also run a procedure by clicking Tools in the menu and selecting Run Procedure or by right-clicking the name of a procedure in the Overview and selecting [Run].

Note: If you do run a procedure from the Overview, you do not have the option of specifying an If test.

From the main menu, select Tools and choose Run Procedure to display the Run Procedure dialog. The Run Procedure list box allows you to select the procedure to be run. If no procedures have been created, the list box in the dialog will be empty.

In command mode or from the menu, you can specify If and While. However, you cannot use both If and While in the same Do command. The If test is evaluated just once to determine if the procedure should be executed and is not applied individually to each record in the file. If the test evaluates as false for the current record, the procedure is not executed. Therefore, you cannot place a Do command within a Group command. See the If and While explanations below.

Note: If you discover that your procedure is not the way you want it, you can edit it. Right-click the procedure name in the Overview and select “Open”.

Parameters

The Do command has the following common command parameters: If and While. For a description, see Command Parameters.

Command Mode Syntax

DO [procedure-name| procedure-name.procedure-label |.procedure-label]

<IF test|WHILE test>¿

If you use a While test in a Do command, the processing speed may be slower because the commands in the procedure are run repeatedly until the While test becomes false.

When using While in a Do command, ensure that your test eventually turns false because there is no protection against “infinite loops”. If you do create an infinite loop, press ESC to get out of it.

The optional .procedure-label parameter enables calling of a sub-procedure contained within a procedure file (.PRO). For more information on Procedure Labels see Procedure Labels.

Note: The optional .procedure-label parameter is only available in command mode.

To call a procedure label, specify the name of the procedure file containing the Procedure Label followed by the name of the Procedure Label:

DO TEST.GET_NAME

When the Procedure Label is called from within the same PRO file that is currently executing then the procedure name should be omitted:

DO .GET_NAME

This allows portable renaming of the procedure file itself without breaking any internal references.