Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Engineering

IF Construct

  • Last UpdatedOct 24, 2022
  • 2 minute read

The full form of an if-construct is as follows:

if (!Word EQ 'Peanuts' OR !Word EQ 'Crisps') then!Snacks = !Snacks + 1

 !Meal = FALSE

elseif ( !Word EQ 'Soup') then

 !Starters = !Starters + 1

 !Meal = TRUE

elseif (!Word EQ 'Fruit' Or !Word EQ 'IceCream' ) then

 !Puddings = !Puddings + 1

 !Meal = TRUE

else

 !MainCourse = !MainCourse + 1

 !Meal = TRUE

endif

Each BOOLEAN expression, such as (!Word EQ 'Soup'), is examined in turn to see whether it is TRUE or FALSE. As soon as an expression that is TRUE is encountered, the following block of commands is executed.

Once a block of commands has been executed, everything else up to the endif is ignored.

The else command is optional. If it is included, you can be sure that exactly one command block within the if-construct will be executed.

The elseif commands are also optional. Once one of the elseif expressions has been found to be TRUE, any remaining elseif commands are ignored.

Thus the simplest form of the if-construct is:

if ( !Number LT 0 ) then

     !Negative = TRUE

endif

You may not concatenate the commands into one line, so the following are not allowed:

if ( !Number LT 0 ) then  !Negative = TRUE endif

$* WRONG

if ( !Number LT 0 )   !Negative = TRUE

$* WRONG

Note:
That expressions such as:
if ( !TrueValue OR !UnsetValue)
if ( !FalseValue AND !UnsetValue)

Ignore !UnsetValue if the value is not required to determine the outcome of the expression. The same is true for PML functions which have returned an error.

TitleResults for “How to create a CRG?”Also Available in