Operator: __VARINFO
The operator is an extension of the IEC 61131-3 standard.
The operator yields information about a variable. You can save the information as data structure in a variable of data type __SYSTEM.VAR_INFO.
Syntax in the declaration
<name of the info variable> : __SYSTEM.VAR_INFO; // Data structure for info variable
Syntax for calls
<name of the info variable> := __VARINFO( <variable name> ); // Call of the operator
FUNCTION_BLOCK FB_Velocity
VAR_INPUT
rVelocity: REAL := 1.2;
END_VAR
VAR_OUTPUT
END_VAR
VAR
infoVelocity: __SYSTEM.VAR_INFO; //Info of Velocity
END_VAR
infoVelocity := __VARINFO(rVelocity); // Gets the info of Velocity locallyPROGRAM PLC_PRG
VAR
iCounter : INT := 0; // Counts the calls
infoCounter : __SYSTEM.VAR_INFO; //Info of Counter
arrA : ARRAY [1..2, 1..2, 1..2] OF INT := [0, 1, 2, 3, 4, 5, 6, 7]; // Stores the A data
infoA : __SYSTEM.VAR_INFO; //Info of A
fbVel : FB_Velocity;
END_VAR
iCounter := iCounter + 1;
infoCounter := __VARINFO(iCounter);
infoA := __VARINFO(arrA);
fbVel();The iCounter and arrA variables are recognized in the application code. The variable information is saved in the infoCounter and infoA variables. Moreover, the FB_Velocity function block is instantiated.
Data Type: __SYSTEM.VAR_INFO
Name | Data Type | Initialization | Description |
|---|---|---|---|
|
| 0 | Address of the variable Example: Note: For bit access of a variable |
|
| 0 | Offset of the variable address (in bytes) Example: Note: If the variable is global, then the offset is relative to the beginning of the area. If the variable is a local variable in a function or method, then the offset is relative to the current stack frame. If the variable is a local variable in a function block, then the offset is relative to the function block instance. |
|
| 0 | Memory area number Example: Means that the variable is not global in the memory, but relative to an instance or on the stack Note: The memory areas are device-dependent. |
|
| 0 | Number of bits (in bytes) Example: Note: If the variable is not an integer data type, then: |
|
| 0 | Memory size of the variable (in bits) Example: |
|
| 0 | Bit address of the variable Requirement: The variable is located in the input memory area |
|
|
| Data type class of the variable Example: Note: For user-defined data types or function block instances, |
|
| ‚‘ | Date type name of the variable as Note: For user-defined data types, the function block name or the DUT name is output. Example: |
|
| 0 | Number of array elements Requirement: The variable has the data type Example: |
|
|
| Elementary basic data type of the array elements Requirement: The variable has the data type Example: |
|
| 0 | Memory size of the array element (in bits) Requirement: The variable has the data type Example: |
|
|
| Information about the memory area
Example: Note: The memory area configuration is device-dependent. |
|
| ‚‘ | Variable name as Example: |
|
| ‚‘ | Comment of the variable declaration Example: |