IF Statement

The IF statement can be used in the Expression (113) command. It is used for conditional branching only within the Expression command.

Format

IFconditionTHEN

statements

ELSIFconditionTHEN

statements

ELSE

statements

END_IF

Notes

Each statement must end with a semicolon (;).

An ELSE cannot precede an ELSIF.

The ELSE and ELSIF are optional.

The spelling ELSIF and ELSEIF are both supported and are equivalent.

Example

Example 1

IF _Axis[0].ActPos> 20.0 THEN

MyREAL:= 92;

END_IF

Example 2

IF MyInput1 = TrueTHEN

MyREAL1 := 34.0;

MyREAL2 := 70023.0;

ELSE

MyDINT := 2;

END_IF

Example 3

IF_Axis[0].StatusBits.InPos = TrueTHEN

MyREAL1 := 34.0;

MyREAL2 := 70023.0;

ELSIFABS(_Axis[0].ActPos) > 20.0 THEN

%QX0.1 := True;

ELSE

MyDINT := 2;

END_IF

 

See Also

Expressions Overview


Send comments on this topic.

Copyright © 2024 Delta Computer Systems, Inc. dba Delta Motion