Attention
IronPLC implements many parts of the IEC 61131-3 standard and is working toward full Structured Text support. Key features still missing include structures and user defined function blocks.
STRING¶
Single-byte character string with a maximum length.
Size |
Variable (default max 254 characters) |
Default |
|
IEC 61131-3 |
Section 2.3.1 |
Support |
Not yet supported |
Literals¶
'Hello, world!'
'It''s escaped'
STRING#'typed literal'
The maximum length can be specified in the declaration:
VAR
name : STRING[50]; (* max 50 characters *)
msg : STRING; (* default max length *)
END_VAR
Constant Length (Vendor Extension)¶
Note
This is a vendor extension not part of the IEC 61131-3 standard. See Enabling Dialects and Features for how to enable it.
With the --allow-constant-type-params flag (or --allow-all), you can
use a global constant for the maximum length instead of a literal:
VAR_GLOBAL CONSTANT
MAX_NAME_LEN : INT := 50;
END_VAR
FUNCTION_BLOCK fb1
VAR_EXTERNAL CONSTANT
MAX_NAME_LEN : INT;
END_VAR
VAR
name : STRING[MAX_NAME_LEN];
END_VAR
END_FUNCTION_BLOCK