A Generic Data Type declares a range of data types is acceptable.
A Generic Data Type begins with the prefix ANY:
Generic Data Type | Implied Types |
---|---|
ANY | Any type elementary or structured |
ANY_ELEMENTARY | ANY_MAGNITUDE, ANY_BIT, ANY_CHARS, or ANY_DATE |
ANY_MAGNITUDE | ANY_INT, ANY_REAL, or TIME |
ANY_INTEGRAL | ANY_INT, or ANY_BIT |
ANY_NUM | ANY_INT, or ANY_REAL |
ANY_REAL | REAL, LREAL |
ANY_INT | SINT, INT, DINT, LINT, USINT, UINT, UDINT, ULINT |
ANY_UNSIGNED | USINT, UINT, UDINT, ULINT |
ANY_SIGNED | SINT, INT, DINT, LINT |
ANY_BIT | BOOL, BYTE, WORD, DWORD, LWORD |
ANY_CHARS | ANY_CHAR, ANY_STRING |
ANY_CHAR | CHAR, WCHAR |
ANY_STRING | STRING, WSTRING |
ANY_DATE | DATE_AND_TIME, DATE |
A Generic Data Type describes the parameters to some built-in functions. For example, the parameter to the ABS() function is ANY_MAGNITUDE. This indicates the function supports SINT, INT, DINT, LINT, REAL, LREAL and TIME.
You can use a Generic Data Type in your own code. For example, as an input parameter to a FUNCTION:
Function GetTypeName : STRING Var_Input Value : ANY_MAGNITUDE; End_Var IF IsTypeOf( Value, ANY_INT ) THEN GetTypeName := 'Integer'; ELSEIF IsTypeOf( Value, ANY_REAL ) THEN GetTypeName := 'Floating Point'; ELSE GetTypeName := 'Interval'; END_IF End_Function
IEC 61131-3 Second Edition: Table 11.
IEC 61131-3 Third Edition: Figure 5.
Note: Using a Generic Data Type in user-defined code is an extension to the IEC 61131-3 standard.
To learn how to test the type of a generic variable.
Elementary Data TypesTo learn about elementary data types.
To learn about other language Common Elements.
For the meaning of terms used in Fernhill SCADA.