Panel For Example Panel For Example Panel For Example

Structure and Function of Siemens TIA Portal Text Block Interfaces

Author : Adrian September 24, 2025

Siemens TIA Portal Text Block Interfaces

Block Declaration and Return Value Syntax

The syntax for block declaration and return values is as follows.

Block Type Syntax Example
Function (FC)

FUNC [TI] ON <name> [:return_data_type]<declaration>

FUNCTION "My_Function" : Int FUNCTION "My_Function" : Void

Function Block (FB)

FUNCTION_BLOCK <name><declaration>

FUNCTION_BLOCK "My_FunctionBlock"

Organization Block (OB)

[OR]GANIZATION_BLOCK <name><declaration>

ORGANIZATION_BLOCK "My_OrganizationBlock"

Text Block Interface Sections

Text block interfaces are divided into different declaration sections. Each section is identified by specific keywords. Different sections can be used depending on the block type.

The order of declaration sections is not significant. A section may appear multiple times within a block interface.

Declaration Section Syntax

The following table lists the syntax structures used for declaration sections.

Declaration Section Syntax
Input parameters

VAR_INPUT [ ] <declaration> END_VAR

Output parameters

VAR_OUTPUT [ ] <declaration> END_VAR

In/out parameters

VAR_IN_OUT [ ] <declaration> END_VAR

Temporary local data

VAR_TEMP <declaration> END_VAR

Static local data

VAR [ ] <declaration> END_VAR

Constants

VAR CONSTANT <declaration> END_VAR

Variable and Constant Declaration Syntax

The syntax used to declare variables and constants is shown below.

Declaration Syntax Example
Variable

<name> : <data_type> [:= <value>];

myBit : BOOL; myBit : BOOL := true;

Constant

<name> : <data_type> := <value>;

[PI] : REAL := 3.141592; myInt: INT := INT#16#7FFF; myString: STRING := 'hello';

AT declaration

<name> AT <reference_variable_name> : <data_type>;

myReferenceToVar2 AT Var_2 : Int;

ARRAY Declarations

The ARRAY data type represents a data structure consisting of a fixed number of elements with the same data type.

The syntax used to declare ARRAY types is shown below.

Declaration Syntax Example
ARRAY

<name> : ARRAY [lower..upper] OF <data_type> := [<initialization_list>];

MyARRAY_1 : ARRAY[0..7] OF BOOL; MyARRAY_1 : ARRAY[0..7] OF BOOL := [1,1,0,0,0,1,0,0];

ARRAY with variable bounds

<name> : ARRAY [*] OF <data_type>;

MyARRAY_1 : ARRAY[*] OF INT; MyARRAY_2 : ARRAY[*, *, *] OF INT;

ARRAY with local-constant bounds

<name> : ARRAY [#<const_name>..#<const_name>] OF <data_type> := [<initialization_list>];

MyARRAY_1 : ARRAY[#LocConst1..#LocConst2] OF INT; MyARRAY_2 : ARRAY[1..#LocConst] OF INT; MyARRAY_3 : ARRAY[1..#LocConst] OF INT := [1,1,0,0];

ARRAY with global-constant bounds

<name> : ARRAY ["<const_name>".."<const_name>"] OF <data_type> := [<initialization_list>];

MyARRAY_1 : ARRAY["GlobConst1".."GlobConst2"] OF INT; MyARRAY_2 : ARRAY[1.."GlobConst", 2..5,#l..#u] OF INT; MyARRAY_3 : ARRAY[1.."GlobConst"] OF INT:= [1,1,0,0];

ARRAY of STRUCT type

<name> : ARRAY[lower..upper] OF Struct <element_name> : <data_type>; <element_name> : <data_type>; ... END_STRUCT := [<initialization_list>];

MyARRAY_1 : Array[0..1] OF Struct mem_1 : Int; mem_2 : Int; END_STRUCT := [ (2,4), (22,44) ];

ARRAY of a UDT

<name> : ARRAY[lower..upper] OF "" := [<parameter_list>];

MyARRAY_1 : Array[0..1] OF MyType := [ (2,4),(22,44) ];

STRING and WSTRING Declarations

STRING and WSTRING data types store multiple characters of a string. Any ASCII character may be used in a string. Characters are enclosed in single quotes.

An initial default value may be specified for the string.

During operand declaration, a maximum string length can be specified using square brackets after the STRING or WSTRING keyword (for example WSTRING[4]). The maximum length can be a literal value or a local/global constant.

If no maximum length is specified, the operand length defaults to 254 characters.

Declaration Syntax Example
STRING

: STRING [:= <value>];

myString: STRING; myString: STRING := 'hello';

WSTRING

: WSTRING [:= <value>];

myWstring: WSTRING; myWstring_var: WSTRING := 'helloWorld';

STRING with defined maximum length

: STRING[[Constant]];

myString: STRING[10]; myString: STRING["globConst"]; myString: STRING[#locConst];