Program code Comment
LISTIDX = MINDEX (INPUT, "M,N,O,P")
+ 1
; The value returned in LISTIDX is 3; because
"N" is the first character in the parameter IN-
PUT from the selection list starting from the
beginning.
PFADIDX = INDEX (INPUT, "/") +1 ; Therefore the following applies: PFADIDX = 1
PROGIDX = RINDEX (INPUT, "/") +1 ; Therefore the following applies: PROGIDX = 12
; The SUBSTR function introduced in the next
section can be used to break-up
variable INPUT into the components "path" and
"module":
VARIABLE = SUBSTR (INPUT,
PFADIDX, PROGIDX-PFADIDX-1)
; Then returns "_N_MPF_DIR"
VARIABLE = SUBSTR (INPUT, PROGIDX) ; Then returns "_N_EXECUTE_MPF"
3.1.4.7 Selection of a substring (SUBSTR)
Arbitrary parts within a string can be read with the SUBSTRING function.
Syntax
<STRING_RES>=SUBSTR(<string>,<index>,<length>)
<STRING_RES>=SUBSTR(<string>,<index>)
Meaning
SUBSTR: This function returns a substring from <string>, starting with <index> with the speci‐
fied <length>.
If the parameter <length> is not specified, the function returns a substring starting with
<index> until the end of the string.
<index>: Start position of the substring within the string. If the start position is after the end of
the string, an empty string (" ") is returned. First character of the string: Index = 0
Range of values: 0 ... (string length - 1)
<length>: Length of the substring. If too long a length is specified, only the substring up to the
end of the string is returned.
Range of values: 1 ... (string length - 1)
Example
Program code Comment
DEF STRING[29] RES
; 1
; 0123456789012345678
RES = SUBSTR("QUITTUNG: 10 to 99", 10, 2)
; RES == "10"
RES = SUBSTR("QUITTUNG: 10 to 99", 10) ; RES == "10 to 99"
Work preparation
3.1 Flexible NC programming
NC programming
Programming Manual, 12/2019, 6FC5398-2EP40-0BA0 453