GET_TYPE_FROM_VARNAME block

Short summary

Name

GET_TYPE_FROM_VARNAME

→POU type

→function

Category

IEC-block, MemoryEnh, block with internal error diagnostic

Conform to →IEC-standard

images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/add.svg not defined in IEC-standard

Graphical interface

images/download/thumbnails/414781825/GET_TYPE_FROM_VARNAME-version-1-modificationdate-1535026982401-api-v2.png

Available since

version 1.42.0 (for logi.CAD 3) and version 2.3.1791 of logi.RTS
images/s/b2ic8e/9012/1ca6q62/_/images/icons/emoticons/warning.svg This block is supported for the built-in PLC only.

Functionality

The block returns the data type of a variable. Enter its instance path in upper case at input NAME. The data type is returned as UDINT value.
logi.cals recommends to call the GET_TYPE_FROM_VARNAME block just once for the variable to request. On the one hand the time behavior might be unpredictable and on the other hand it might take longer to determine the data type.

Restrictions for the usage:

  • The requested variable must have been declared with an elementary data type or an array of these elementary data types. The elementary data types are: REAL, LREAL, USINT, UINT, UDINT, ULINT, SINT, INT, DINT, LINT, TIME, BOOL, BYTE, WORD, DWORD, LWORD, STRING, CHAR, DATE_AND_TIME, DATE or TIME_OF_DAY

  • There must be an instance path for the requested variable. This means that the following variables cannot be requested:

  • The requested variable must writeable from each position of the application (i.e. within and outside of the POU in which the variable has been declared). This means that the following variables cannot be requested:

  • It is only allowed to use the call of the block on the right side of the assignment operator ":=" for →assignments.

Inputs, outputs, return value


Identifier

→Data type

Description

Inputs:

NAME

STRING

instance path of the variable (in upper case)
Use . as separator.

Outputs:

LEN

UINT

length (= memory size) of the variable (in bytes) or 0

STATUS

USINT

state of the operation (result code):

  • 16#00: operation succeeded

  • 16#80: The service is not available.

  • 16#81: The variable has not been found.

  • 16#87: The data type is invalid.

Return value:

UDINT

data type of the requested variable

  • 0: unknown data type (in case of an error)

  • 6: CHAR

  • 7: STRING

  • 8: TIME

  • 9: BOOL

  • 10: SINT

  • 11: INT

  • 12: DINT

  • 13: LINT

  • 14: USINT

  • 15: UINT

  • 16: UDINT

  • 17: ULINT

  • 18: REAL

  • 19: LREAL

  • 20: TIME_OF_DAY

  • 21: DATE_AND_TIME

  • 22: DATE

  • 23: BYTE

  • 24: WORD

  • 25: DWORD

  • 26: LWORD

Input EN and output ENO are available when →calling the block. See "Execution control: EN, ENO" for information on input EN and output ENO.

Internal error diagnostic for block

The block checks whether one of the above restrictions is violated. In such an error case, the output ENO of the block is set to value FALSE (or an equivalent). Moreover, the output STATUS returns the appropriate code (see the above table under STATUS), the output LEN returns the value 0 and the block itself returns 0 (as return value).

Example for usage within ST-editor

Exemplary usage of the GET_TYPE_FROM_VARNAME block
PROGRAM DocumentationExamples
VAR
iExampleGetTypeFromVarname : ExampleGetTypeFromVarname;
END_VAR
iExampleGetTypeFromVarname();
END_PROGRAM
 
FUNCTION_BLOCK ExampleGetTypeFromVarname
VAR
requestedVar : INT;
dataType : UDINT;
CheckSize : UINT;
CheckState : USINT;
CheckENO : BOOL;
END_VAR
IF dataType = 0 THEN
dataType := GET_TYPE_FROM_VARNAME(NAME := 'DOCUMENTATIONEXAMPLES.IEXAMPLEGETTYPEFROMVARNAME.REQUESTEDVAR', LEN => CheckSize, STATUS => CheckState, ENO => CheckENO);
END_IF;
ENO := dataType = 11;
END_FUNCTION_BLOCK

When creating your application within the ST-editor, enter a call of a block by typing the text as requested by the syntax or use Content Assist.