Back

Topic

[KB151]Using the “?VarName” syntax in SCADA Basic

Tags: Scada Basic, Scripting

14 years ago
By RM
Options
Print
Applies to:

PcVue all versions.


Summary:

This article defines when you can use the syntax ‘?VarableName’ in SCADA Basic.


Details:

When you can use ‘?’

The syntax ‘?VariableName’ can only be used in an assignment instruction to force the value of a variable, as in these examples:

  Dim cVarName As Str;
  cVarName = “Register01”;
  ?cVarName = 99″;

Or

  Dim cVarName As Str;
  cVarName = “Register01”;
  @Register02 = ?cVarName;

When you cannot use ‘?’

You cannot use the ‘?VariableName’ syntax to display a variable’s value or to compare it.

For example in the following program:

  Dim cVarName As Str;
  cVarName = “Register01”;

Register01 is a register variable in the variables tree with the value 99. The following PRINT instruction:

  PRINT(?cVarName);

displays the text Register01 rather than the value of Register01.

Similarly in the following code:

  Dim cVarName As Str;
  Dim iReturn As Integer;

  cVarName = “Text01”;
  ?cVarName = “Hello World”;
  Delay(0.2); ‘ To allow assignment of value
  iReturn = CMPSTRING(?cVarName, “Hello World”);

The return code ‘iReturn’ will never be 0 (meaning that the contents are identical) because it is not possible to use the ‘?VarName’ syntax in an instruction such as CMPSTRING.


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