Variables

variables

Variable names can consist of numbers and letters in any order. A name that consists only of digits is not permitted. No distinction is made between upper and lower case. The length of the name is not mandatory.

The definition is made by specifying the type followed by the variable name. Several variables of the same type can be defined one after the other. The individual names must be separated by commas.Example:
String name, path
long count
window win  

Array

Variables can also be defined as an array. The array size is placed after the name in square brackets:
long numarr [16] 

Block

A block consists of any sequence of numbers, strings and boolean values. The maximum length of such a block is 65,496 bytes. 

Boolean

The “Boolean” type can have two states. All non-zero values ​​are true, the value zero is false. The words true and false are reserved for entering Boolean constants.

Caution: When querying Boolean values, for example with IF … THEN … ENDIF, no comparison operators (=,>, <, ..) may be specified. The query is made directly on the variable (e.g. IF BOOL1 THEN …, query on true) or with the NOT operator (e.g. IF NOT BOOL1 THEN …., query on false). 

Double

Floating point numbers are determined by the type “Double”. This is an 8 byte IEEE floating point number with 15-digit precision.

Value range: 1.7 * 10 -308 to 1.7 * 10 +308

The floating point numbers can be specified in decimal or exponential notation. The exponent is introduced by e or E. The number cannot contain any spaces.

Example: 1.234, .015, -1.345E + 3

GraphPic variables

GraphPic variables are specified in plain text within the script and must be delimited by double quotes. First the group name and then the variable name, separated by a colon:

“Internal: Wert1” {Variable Wert1 from the group Internal}

Long

As usual with GraphPic, all integer values ​​are treated as 4 byte numbers with a sign.

Value range: -2,147,483,648 to 2,147,483,647.

All integer numbers can also be specified in hexadecimal (prefixed 0x) or octal (prefixed 0).

Example: 0x1A, 035

Static variables

Script variables only retain their value during a run. The next time the script is called, the variables are set to zero values ​​again. If values ​​are to be retained throughout the project, the type specification must be preceded by the keyword “static” in the variable declaration. Static variables are only initialized to zero values ​​at the start of the project:

static long l1 {retains its value}

long l2 {is set to zero with every run}

String

A string is a sequence of zero or more ASCII characters. The string can have a length of up to 65,498 characters and is terminated with a null character. If a constant string is entered, it must be limited by single quotation marks.

Example: ‘I am a string’.

If a string is to contain characters that cannot be displayed (e.g. line feed), escape sequences can be entered. The escape sequences begin with a backslash (\).

A backslash in combination with octal or hexadecimal numbers represents the ASCII or control code that corresponds to this value. A carriage return can be represented by ‘\x0D’, for example. If a backslash is to be used in the string, it must be doubled (\\). This is necessary, for example, when specifying directory paths. The following table contains all escape sequences:

sequencevaluecharacterimportance
\r\n0x0D0ACRLFnew line
\a0x07BELAlarm tone
\b0x08BSBackspace
\f0x0CFFForm feed
\n0x0ALFLine feed
\r0x0DCRCarriage return
\t0x09HTHorizontal tab
\v0x0BVTVertical tab
\\0x5C\Backslash
\’0x27Single apostrophe
\”0x22Double apostrophe
\?0x3F?Question mark
\0  Octal number
\x  Hexadecimal number
\X  Hexadecimal number

Window

The type “window” occupies 2 bytes of memory and contains an index to a VisXpert window. This must be specified in plain text in the script and must be enclosed by double quotation marks.

Comments

Any number of comments can be added to the script. The comments are separated from the program part by curly brackets. Comments can span several lines and be in the middle of a sequence of instructions. Nesting of comments is possible. Single-line comments are introduced by 2 consecutive slashes.