*IF

*IF, VAL1, Oper1, VAL2, Base1, VAL3, Oper2, VAL4, Base2
Conditionally causes commands to be read.

Compatible Products: – | Pro | Premium | Enterprise | Ent PP | Ent Solver | DYNA

Argument Descriptions

VAL1

First numerical value (or parameter which evaluates to a numerical value) in the conditional comparison operation. VAL1, VAL2, VAL3, and VAL4 can also be character strings (enclosed in quotes) or parameters for Oper = EQ and NE only.

Oper1

Operation label. A tolerance of 1.0E-10 is used for comparisons between real numbers:

EQ -- 

Equal (for VAL1 = VAL2).

NE -- 

Not equal (for VAL1 ≠ VAL2).

LT -- 

Less than (for VAL1 < VAL2).

GT -- 

Greater than (for VAL1 > VAL2).

LE -- 

Less than or equal (for VAL1   VAL2).

GE -- 

Greater than or equal (for VAL1   VAL2).

ABLT -- 

Absolute values of VAL1 and VAL2 before < operation.

ABGT -- 

Absolute values of VAL1 and VAL2 before > operation.

VAL2

Second numerical value (or parameter which evaluates to a numerical value) in the conditional comparison operation.

Base1

Action based on the logical expression (Oper1) being true. If false, continue reading at the next line. This is conditional, except for the IF-THEN-ELSE constructs described below; any of the following constructs (through Base1 = THEN) cause all subsequent fields to be ignored:

:label -- 

A user-defined label (beginning with a colon (:), 8 characters maximum). The command reader will skip (and wrap to the beginning of the file, if necessary) to the first line that begins with the matching :label.


Caution:   This label option may not be mixed with do-loop or if-then-else constructs.


STOP -- 

This action will cause an exit from the ANSYS program at this line, unless running in interactive mode. In interactive mode, the program will not stop.

EXIT -- 

Exit the current do-loop [*EXIT].

CYCLE -- 

Skip to the end of the current do-loop [*CYCLE].

THEN -- 

Make this *IF an if-then-else construct (see below).

The following optional values determine the connection between the two logical clauses Oper1 and Oper2

AND --

True if both clauses (Oper1 and Oper2) are true.

OR --

True if either clause is true.

XOR --

True if either (but not both) clause is true.

VAL3

Third numerical value (or parameter which evaluates to a numerical value).

Oper2

Operation label. This will have the same labels as Oper1, except it uses Val3 and Val4. A tolerance of 1.0E-10 is used for comparisons between real numbers.

VAL4

Fourth numerical value (or parameter value which evaluates to a numerical value).

Base2

Action based on the logical expression (Oper1 and Oper2) being true. They will be the same values as Base1, except as noted.

Command Default

Read commands sequentially.

Notes

Conditionally causes commands to be read from a specific block or at a specific location. Twenty levels of nested *IF blocks are allowed. Jumping to a :label line is not allowed with keyboard entry. Jumping into, out of, or within a do-loop or an if-then-else construct to a :label line is not allowed. Using *IF interactively or from the command line prevents rereading the file to find a label. To do so, use batch mode or /INPUT.

The following is an example of an if-then-else construct:

*IF,VAL1,Oper,VAL2,THEN

----

*ELSEIF,VAL1,Oper,VAL2

----

*ELSEIF,VAL1,Oper,VAL2

----

*ELSE

----

*ENDIF

where "----" represents a block of any number of commands. Any number of *ELSEIF clauses (or none) may be included (in the location shown). One *ELSE clause (at most) may be included (in the location shown). The *IF command is executed by evaluating its logical expression. If it is true, the block of commands following it is executed. The construct is considered to be complete and the command following the *ENDIF is executed next. If the logical expression is false, the next *ELSEIF command (if any) following the block is executed. The execution logic is the same as for *IF. The effect is that the logical expressions in the *IF and the *ELSEIF commands are sequentially tested until one is found to be true. Then the block of commands immediately following the expression is executed, which completes the execution of the if-then-else construct. If all *IF and *ELSEIF expressions are false, the block following the *ELSE command is executed, if there is one. Only one block of commands (at most) is executed within the if-then-else construct. If a batch input stream hits an end-of-file during a false *IF condition, the ANSYS run will not terminate normally. You will need to terminate it externally (use either the Linux “kill” function or the Windows task manager). The *IF, *ELSEIF, *ELSE, and *ENDIF commands for each if-then-else construct must all be read from the same file (or keyboard).

This command is valid in any processor.

Menu Paths

This command cannot be accessed from a menu.

Release 18.2 - © ANSYS, Inc. All rights reserved.