Alias
A data type alias is the declaration of a user-defined data type that can be used to create an alternative name for a data type or a function block.
You declare an alias in a DUT object that you create using the command Add > DUT in the context menu of the PLC project tree in the project.
Syntax:
TYPE <DUT name> : <type name>;
END_TYPE
Permitted types
|
|
Sample:
PLC variable of type T_Message is always a string with 50 characters.
TYPE T_Message : STRING[50];
END_TYPE
Declaration:
sMessageA : T_Message;
Program:
sMessageA := 'This is a message';
Sample:
Alias data type for variables of type STRING or ARRAY if they require a specific length.
Declaration
TYPE FRAME : ARRAY[0..1499] OF BYTE; END_TYPE
TYPE SYMBOL : STRING(512); END_TYPE
Call
PROGRAM MAIN
VAR
aFrame : FRAME;
sSymbol : SYMBOL;
END_VAR
PLC variable of type T_Message is always a string with 50 characters
Sample:
Alias data type for variables that require a different start value than the one provided by the compiler.
TYPE INDEX : DINT := -1; END_TYPE
Sample:
Alias data type for variables of a specific type that are only to contain a specific subrange of values of the original type.
{attribute 'qualified_only'}
VAR_GLOBAL CONSTANT
cMaxRune : DINT := DINT#16#0010FFFF;
END_VAR
TYPE RUNE : DINT(0..GVL.cMaxRune); END_TYPE
See also: