IF command

Specifies a condition that must evaluate to true in order to execute a command.

Syntax

IF test command

Parameters

Name Description
test

The condition that must be met for command to be run.

command

Any valid ACLScript command to run if test evaluates to true.

Examples

Running a command conditionally

You want to use CLASSIFY on a table, but only if the v_counter variable is greater than ten:

IF v_counter > 10 CLASSIFY ON Location TO "Count_by_Location.fil" OPEN

Running a command based on a user decision

You want to allow the script user to decide whether to classify a table.

In your script, you include a dialog box with a check box that if selected allows the CLASSIFY command to run. The check box stores a True or False input value in the logical variable v_classify_checkbox.

You use an IF test to determine the value of v_classify_checkbox, and if the value is True, CLASSIFY executes:

IF v_classify_checkbox=T CLASSIFY ON Location TO "Count_by_Location.fil" OPEN

Remarks

IF command versus IF parameter

The logic of the IF command differs from the IF parameter that is supported by most commands:

  • IF command determines whether the associated command runs or not, based on the value of the test expression
  • IF parameter determines whether the command runs against each record in an ACL table based on the value of the test expression

Decision making in scripts

In a script, you can enter a series of IF command tests and run different commands based on the results. The IF command can be also be used to test the value of a variable to determine if further processing should occur.

[ Back to top ]

(C) ACL Services Ltd. All Rights Reserved. Thursday, October 4, 2018