Generic Data Types

Help Contents

Introduction

A Generic Data Type declares a range of data types is acceptable.

A Generic Data Type begins with the prefix ANY:

Generic Data TypeImplied Types
ANYAny type elementary or structured
ANY_ELEMENTARYANY_MAGNITUDE, ANY_BIT, ANY_CHARS, or ANY_DATE
ANY_MAGNITUDEANY_INT, ANY_REAL, or TIME
ANY_INTEGRALANY_INT, or ANY_BIT
ANY_NUMANY_INT, or ANY_REAL
ANY_REALREAL, LREAL
ANY_INTSINT, INT, DINT, LINT, USINT, UINT, UDINT, ULINT
ANY_UNSIGNEDUSINT, UINT, UDINT, ULINT
ANY_SIGNEDSINT, INT, DINT, LINT
ANY_BITBOOL, BYTE, WORD, DWORD, LWORD
ANY_CHARSANY_CHAR, ANY_STRING
ANY_CHARCHAR, WCHAR
ANY_STRINGSTRING, WSTRING
ANY_DATEDATE_AND_TIME, DATE

Remarks

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

Standards Compliance

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.

Further Information

Type Information Functions

To learn how to test the type of a generic variable.

Elementary Data Types

To learn about elementary data types.

Common Elements

To learn about other language Common Elements.

Glossary

For the meaning of terms used in Fernhill SCADA.