Back

Topic

[KB145]Limitations of the ‘IF’ instruction

Tags: Scada Basic, Scripting

14 years ago
By RM
Options
Print
Applies to:

PcVue all versions.


Summary:

This article describes some limitations of the ‘IF’ instruction


Details:

In SCADA Basic you cannot combine a test of an register variable and bit variable using “||” or “&&”.

Example

This example uses these variables:

IF

A test of the variables as follows:

IF ((@PRODUCTA.VALVE.CMD == 1) && (@PRODUCTA.TANK.SETPOINT > 12))   THEN
  PRINT(“condition OK”);
ELSE
  PRINT(“condition Not OK”);
END IF

causes an error message to appear in the programming results window:

18/11/05,16:03:24 Program (init) Branch () Line 15 Type mismatch (null)

On the other hand, this test using two register variables:

IF((@PRODUCTB.TANK.SETPOINT == 54) && (@PRODUCTA.TANK.SETPOINT > 12)) THEN
  PRINT(“condition OK”);
ELSE
  PRINT(“condition Not OK”);
END IF

produces a normal result, depending on the values of the variables, as follows:

condition OK
or
condition Not OK


Created on: 05 Nov 2010 Last update: 13 May 2024