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

Job planning
Hide thumbs Also See for SINUMERIK 840D sl:
Table of Contents

Advertisement

Flexible NC programming
1.10 String operations
Example: separating an input string into path and module names:
DEF INT PATHIDX, PROGIDX
DEF STRING[26] INPUT
DEF INT LISTIDX
INPUT = "/_N_MPF_DIR/_N_EXECUTE_MPF"
LISTIDX = MINDEX (EINGABE, "M,N,O,P") + 1
PATHIDX = INDEX (INPUT, "/") +1
PROGIDX = RINDEX (INPUT, "/") +1
VARIABLE = SUBSTR (INPUT, PATHIDX,
PROGIDX-PATHIDX-1)
VARIABLE = SUBSTR (INPUT, PROGIDX)
1.10.7

Selection of a substring

Function
This functionality extracts a substring from a string. For this purpose, the index of the first
character and the desired string length (if applicable) are specified. If no length information is
specified, then the string data refers to the remaining string.
Programming
Syntax
STRING_ERG = SUBSTR (STRING,INT)
STRING_ERG = SUBSTR(STRING,INT, INT)
Semantics
In the first case, the substring from the position specified in the first parameter to the end of
the string is returned.
In the second case, the result string goes up to the maximum length specified in the third
parameter.
If the initial position is after the end of the string, the empty string (" ") will be returned.
A negative initial position or length triggers an alarm.
Example
DEF STRING [29] ERG
ERG = SUBSTR ("ACK: 10 to 99", 10, 2)
1-32
The value returned in LISTIDX is 3
because "N" is the first char from the
selection list in parameter INPUT,
searching from the beginning.
;Therefore: PATHIDX = 1
;Therefore: PATHIDX = 1
;The SUBSTR function introduced in the
next section can be used to break up
variable INPUT into the components "Path"
and "Module":
;returning "_N_MPF_DIR"
;returning "_N_EXECUTE_MPF"
Result type: INT
Result type: INT
;Therefore: ERG == "10"
Programming Manual, 03/2006 Edition, 6FC5398-2BP10-1BA0
Job planning

Advertisement

Table of Contents
loading

Table of Contents