Global, valid throughout main program (V.S.)

The code "V.S. ....” permits the definition of self-defined variables which retain the same names and the last values assigned at all program levels and all following (main) HC programs. After RESET, these variables also remain valid. The values of the variables can only be changed by overwriting. The variables themselves can only be deleted by #DELETE or a controller restart. V.S. variables may be assigned values in REAL format. As of Build V2.11.2032.08 declarations of other data types with initial values are possible.

Syntax:

V.P.<FREE_DEF>

global variable not valid after (main) program end

<FREE_DEF>

User-defined name consisting of any number of characters (excluding blanks, tabulators, comments, comparison operators, mathematical operators, square brackets).

Programing Example

prg_example

Global, valid (main) program global (V.S.)

Create V.S. variables with and without assigning data types and initial values.

:

#VAR

  V.S.VAR1                      ;REAL64, 0.0

  V.S.VAR2 : UNS32 = 200        ;UNS32, 200

  V.S.VAR3 : REAL64 = 11.34     ;REAL64, 11.34

  V.S.VAR4 : BOOLEAN            ;BOOLEAN, FALSE or 0

  V.S.VAR[5] = [5,10,10,15,20]  ;Array with REAL64 values

#ENDVAR

:

XV.S.VAR[4]        ;X20.0

:

The maximum number of self-defined V.S. variables is fixed [6]-6.22.