3.1.4.8 Reading and writing of individual characters
Individual characters can be read and written within a string.
The following supplementary conditions must be observed:
● Only possible with user-defined variables, not with system variables
● Individual characters of a string are only transferred "call by value" for subprogram calls
Syntax
<Character>=<string>[<index>]
<Character>=<string_array>[<array_index>,<index>]
<String>[<index>]=<character>
<String_array>[<array_index>,<index>]=<character>
Meaning
<string>: Any string
<character>: Variable of type CHAR
<index>: Position of the character within the string.
First character of the string: Index = 0
Range of values: 0 ... (string length - 1)
Examples
Example 1: Variable message
Program code Comment
; 0123456789
DEF STRING [50] MESSAGE = "Axis n has reached position"
MESSAGE [6] = "X"
MSG (MESSAGE) ; "Axis X has reached position"
Example 2: Evaluating a system variable
Program code Comment
DEF STRING[50] STRG ; Buffer for system variable
...
STRG = $P_MMCA ; Load system variable
IF STRG[0] == "E" GOTO ... ; Evaluating the system variable
Example 3: Parameter transfer "call by value" and "call by reference"
Program code Comment
; 0123456
DEF STRING[50] STRG = "Axis X"
DEF CHAR CHR
...
Work preparation
3.1 Flexible NC programming
NC programming
454 Programming Manual, 12/2019, 6FC5398-2EP40-0BA0