Variables / Constants / Data Types

At the beginning of each program, you have to declare the local variables and constants. These are local information carrier of the script and exist independent from the data point elements exclusively in main memory. A corresponding data type must be assigned to each variable. For more information on the data types, see online help under Data types.

  int     a;
  //Variable 'a' des Typs Ganzzahl (int)
  float   b,c,d,e;
  //Mehrere Variablen vom Typ float
  bool    switchOn;
  //Einzelne Variable vom Typ bool
  const   float pi = 3.1415
  //Deklaration einer Konstanten (float)
  //weiterer Programmcode könnte hier stehen
  // ...
  b = c + d - e;
  //Arithmetischer Ausdruck / Zuweisung
  float f;
  //In-Code Deklaration einer Variable
  f = 42.42;
  b = b + f;
  // weiterer Programmcode könnte hier stehen...

You can declare variables at the beginning or later in the code. By using the prefixed key word const and by defining a value at the declaration, you define a constant (Declaration with Initialization).

You can define several variables of the same data type separated by a comma "," after the type definition. Otherwise you have to complete each declaration as well as other statements with a semicolon ";".

The list of all possible data types comprises all types possible for data point elements as well as at runtime modifiable types like "anytype" or "mixed" - also associative arrays are possible in the form of "mapping". See also online help on the page Data types and Mapping.

In addition to the local variables of an individual script, CONTROL also knows a number of further variable types - for more information see chapter Variable and constants:

  • Script-global variables(declaration before main() statement of the current program),
  • Panel global variables (declaration before the functions of the panel library in the field "General" next to eventScripts of the panel),
  • Manager-global variables (declaration before the functions of a manager-global library or using the Control function addGlobal())