Selection Of A Substring (Substr) - Siemens SINUMERIK 840D sl Programming Manual

Nc programming
Hide thumbs Also See for SINUMERIK 840D sl:
Table of Contents

Advertisement

Program code
LISTIDX = MINDEX (INPUT, "M,N,O,P")
+ 1
PFADIDX = INDEX (INPUT, "/") +1
PROGIDX = RINDEX (INPUT, "/") +1
VARIABLE = SUBSTR (INPUT,
PFADIDX, PROGIDX-PFADIDX-1)
VARIABLE = SUBSTR (INPUT, PROGIDX)
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:
<index>:
<length>:
Example
Program code
DEF STRING[29] RES
;
;
RES = SUBSTR("QUITTUNG: 10 to 99", 10, 2)
RES = SUBSTR("QUITTUNG: 10 to 99", 10)
NC programming
Programming Manual, 12/2019, 6FC5398-2EP40-0BA0
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.
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 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)
1
0123456789012345678
3.1 Flexible NC programming
Comment
; 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.
; Therefore the following applies: PFADIDX = 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":
; Then returns "_N_MPF_DIR"
; Then returns "_N_EXECUTE_MPF"
Comment
; RES == "10"
; RES == "10 to 99"
Work preparation
453

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sinumerik 840de sl

Table of Contents