Skip to main content

Alias

A data type alias is the declaration of a user-defined data type with which an alternative name for a base type, data type, or function block is generated.

You make the type declaration of an alias in a DUT object which you create in the ProjectAdd ObjectDUT menu or in the context menu of an application.

For more information, see: DUT

Syntax

TYPE <identifier> : <data type name> ;

END_TYPE

Table 21. Permitted types

<data type name>

  • Base data type

  • Data type with specified size

  • Function Block



Example 234. Example

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 PLC_PRG
VAR
	frameF : FRAME;
	symbolS : SYMBOL;
END_VAR


Example 235. Example

Alias data type for variables which require a different initial value than the one provided by the compiler

TYPE INDEX : DINT := -1; END_TYPE


Example 236. Example

Alias data type for variables of a specific type which should apply only a specific subset of values of the original type

{attribute 'qualified_only'}
VAR_GLOBAL CONSTANT
	c_diMaxRune : DINT := DINT#16#0010FFFF;
END_VAR
TYPE RUNE : DINT(0..GVL.c_diMaxRune); END_TYPE


Example 237. Example

Alias data type for types from another namespace

For example, for types from a subordinate library which should be available in the current namespace.

TYPE ENCODING: SBB.ENCODING; END_TYPE (*ENUM*)
TYPE RUNE : UTF8.RUNE;  END_TYPE (*SUBTYPE*)
TYPE INFO : STR.IFNFO;  END_TYPE (*STRUCT*)
TYPE IBuilder : SBB.IBuilder; END_TYPE (*INTERFACE*)
TYPE Tange: SBB.Range; END_TYPE (*FUNCTION_BLOCK*)

Tip

This means that in many cases, a container library can be omitted because all types of subordinate libraries become part of their own library in this way.