Executable Block Statements - IF_SET (Conditional Execution)

Sometimes the decision to execute statements depends on whether or not the indicator of a variable is "on", i.e. its value has been reset, or on some logical condition. These conditions can be checked and the execution of the appropriate statements can be triggered by the IF_SET statement.

It is also possible to specify an alternative action that should be performed if the indicator of the variable is "off" or if the logical condition is false. This is done by including an ELSE clause in the IF_SET statement.

All IF_SET statements must be terminated by END_IF.

Example 1:

IF_SET (X_CURPOS) OUTPUT $ "X" X_CURPOS ; END_IF ;

Example 2:

IF_SET (X_CURPOS) OUTPUT $ "X" X_CURPOS ;ELSE X = X + 1 ;END_IF ;

In the examples, if the indicator of the Toolpath Variable X_CURPOS is "on", then the literal constant X and the value of X_CURPOS will be sent to output. In addition, the new line character (in this case, the dollar sign $) will trigger the series of operations which was defined with the NEW_LINE_IS declaration statement before the blocks.In the first example, if the indicator of X_CURPOS is "off" the executable statements which follow will be ignored. In the second statement, the statement following ELSE will be executed, i.e., X will be incremented by 1.

Any one of the following logical arguments may be used in an IF_SET statement:

(variable _EQ_ variable)

Checks if two numeric or character variables are identical.

(variable _NE_ variable)

Checks if two numeric or character variables are not identical.

(variable _GT_ variable)

Checks if the first numeric variable value is greater than the second.

(variable _LT_ variable)

Checks if the first numeric variable value is less than the second.

(variable _LE_ variable)

Checks if the first numeric variable value is less than or equal to the second.

(variable _GE_ variable)

Checks if the first numeric variable value is greater than or equal to the second.

Notes:

  • Comparison of two variables in the CHARACTER format is not supported. If a variable in the CHARACTER format must be checked, it should be compared to a string. For example:

IF_SET (FILE_EQ_ "any_file")

The comparison to string is case sensitive and includes blanks (except for trailing blanks).

  • Comparison of variables that have a different format is not recommended.

Example:

IF_SET (X _EQ_ Y)
OUTPUT \J "X & Y = " X_CURPOS ;
ELSE
OUTPUT \J "X = " X_CURPOS " Y = " Y_CURPOS ;
END_IF ;

In the example, if X_CURPOS and Y_CURPOS are equal (e.g. 1234), the output will be:

    • the literal constant X & Y =

    • and the value of the Toolpath Variable X_CURPOS.

The output: X & Y = 1234.

If they are not equal (e.g. 1234,12), the output will be:

    • the literal constant X =,

    • the value of X_CURPOS,

    • the literal constant Y =

    • and the value of Y_CURPOS.

The output: X = 1234 Y = 12

The comparison is in two steps:

First Step

Second Step

First Step

Check if the two numbers are equal.

This is done for ALL options: EQ, NE, GT, LT, GE, LE

Comparing two variables:

Two strings are compared. When comparing numbers that have the same value but different format, the result might be unexpected.

Example:

DFPOST FORMAT:

USER_1:

3,3,3,3,NO,NO,....

USER_2:

4,4,4,4,NO,NO,.....

exf file:

FORMAT (USER_1) A ;

    FORMAT (USER_2) B ;
A = 1.123 ;
B = 1.123 ;
IF_SET (A _EQ_ B)

    OUTPUT \J A " is equal to" b ;

    ELSE

    OUTPUT \J A " is NOT equal to" b ;

    END_IF ;

During the DFEXF compilation, the following warning will appear:

***WARNING IN LINE 18
IF_SET (A _EQ_ B)
MIXED FORMATS ARE USED IN ONE EXPRESSION
RESULT MAY BE INCORRECT.

Output file: 1.123 is NOT equal to 1.123.

Comparing a variable with a number:

The variable is rounded according to the FORMAT and then compared with the number.

Second Step

If the two numbers are not equal, they are compared in double-precision to check which is larger.

IF_SET statements may be nested in different ways. Some examples follow:

Example 1

Example 2

Example 3

IF_SET IF_SET

IF_SET

IF_SET

IF_SET

IF_SET

IF_SET

END_IF

ELSE

END_IF

IF_SET

END_IF

END_IF

END_IF

ELSE

END_IF

END_IF

END_IF

Some functionality may be dependent on the product package. Contact your Reseller if you require a license.