-

Strings

User-defined strings (STRINGs) are composed of a specified or a variable number of characters. If a number is specified in brackets at the string type definition, this is considered as fixed string length. If no length is specified, the string can contain any number of characters within the valid range.

Valid string length: the number of valid characters of strings is 1 up to 32766.

Note
User-defined STRINGs can also be defined on the 'Variables' and 'Data List' tables in the 'Type' column using the following syntax:
 
       STRING_<size>
 
There is no definition in a data type worksheet. The user-defined STRING of length size will be created invisibly. The user-defined string is not available on a data type worksheet.
 
Example:
STRING_35 (user-defined string with a maximum of 35 characters)

Data type definition
Variable declaration
('Variables'/Data List)
Use in code

The following applies to remote access to STRING variables, for example, from the OPC UA, PLCnext Engineer HMI and the online functions of PLCnext Engineer:

Note
Remote access limitation: The read and write access to STRING variables from outside the controller application is limited to 511 bytes.
The reason for this is a limitation in the Remote Service Calls (RSC) IDataAccessService and ISubScriptionService. RSCs are services for the communication between processes and between devices. They provide the API to enable access to all core components of the PLCnext Technology firmware.

Note
Besides user-defined strings, defined in a data type worksheet, the IEC 61131-3 standard defines default strings. In contrast to user-defined strings, default STRINGs can directly be declared in variables tables by selecting the 'Type' STRING. No data type definition is required. A default string has the length of 80 characters.

Initializing STRINGs

An initial value is set for a string in the variables table by entering the initialization string into the 'Init' column enclosed in single quotation marks.

Further Info
See also the topic "User-defined data types".