You are here: Commands > If

If

The If command allows you to specify a condition that must be met in order for the command following it to be executed. The condition applies to the entire command and must be met for the command to continue processing.

The If command evaluates the test when Analyzer first encounters the command. If the test evaluates as true, the command following is processed. If the test returns false, Analyzer ignores the rest of the command.

This differs from the If condition at the command level which tests each record of the file and executes the command on the records that meet the test.

In a procedure, you can enter a series of If command tests and run different commands based on the result. The If command is most useful for testing a variable to determine if the file will be processed.

Any valid Analyzer command may follow the test.

This command can only be issued in command mode and is only useful in procedures.

Note: The If command cannot be used within a Group command in a procedure.

Command Mode Syntax

IF condition COMMAND

Examples

To perform a sample, but only if the variable count1 is greater than ten:

IF Count1 > 10 SAMPLE Amount...

Assume you had a previous Dialog command, with a checkbox control that creates the variable StatCheckBox (so the user can check to display statistics). You could use the following command to produce the statistics, if requested:

IF StatCheckBox STATISTICS ALL