PERFORM

In this section:

How to:

Reference:

You can use the PERFORM command to pass control to a Maintain function. Once that function is executed, control returns to the command immediately following the PERFORM.


Top of page

x
Syntax: How to Use the PERFORM Command

The syntax of the PERFORM command is

PERFORM functionname [()] [;]

where:

functionname

Specifies the name of the function to perform.

()

Is optional. If you omit the word PERFORM and just use the function name, parentheses are required.

;

Terminates the command. Although the semicolon is optional, it is recommended that you include it to allow for flexible syntax and better processing. For more information about the benefits of including the semicolon, see Terminating a Command's Syntax.

For example, to perform the function named NextSet, issue the command:

PERFORM NextSet;

Top of page

x
Reference: Commands Related to PERFORM

Top of page

x
Using PERFORM to Call Maintain Functions

When you call a function as a separate statement (that is, outside of a larger expression), if the preceding command can take an optional semicolon terminator but was coded without one, you must call the function in a COMPUTE or PERFORM command. (You can use PERFORM for Maintain functions only, though not for Maintain functions that return a value.)

For example, in the following source code, the NEXT command is not terminated with a semicolon, so the function that follows it must be called in a PERFORM command:

NEXT CustID INTO CustStack
PERFORM VerifyCustID();

However, in all other situations, you can call functions directly, without a PERFORM command. For example, in the following source code, the NEXT command is terminated with a semicolon, so the function that follows it can be called without a PERFORM command:

NEXT CustID INTO CustStack;
VerifyCustID();

Note: When calling a function without using a PERFORM command, you must include parentheses.

For more information about terminating commands with semicolons, see Terminating a Command's Syntax.


Top of page

x
Using PERFORM With Data Source Commands

A PERFORM can be executed in a MATCH command following an ON MATCH or ON NOMATCH command, or in NEXT following ON NEXT or ON NONEXT. In the following example, the function NotHere is performed after a NOMATCH condition occurs:

ON NOMATCH PERFORM NotHere;


Top of page

x
Nesting PERFORM Commands

PERFORM commands can branch to functions containing other PERFORM commands. As each ENDCASE command is encountered, control returns to the command after the most recently executed PERFORM command. In this manner, control eventually returns to the original PERFORM.


Top of page

x
Avoiding GOTO With PERFORM

It is recommended that you do not include a GOTO command within the scope of a PERFORM command. See GOTO for information on the incompatibility of the PERFORM and GOTO commands.


WebFOCUS