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

Hide thumbs Also See for SINUMERIK 828D:
Table of Contents

Advertisement

Flexible NC programming
1.9 String operations
Example
Breaking up an input into path and block names
Program code
DEF INT PFADIDX, PROGIDX
DEF STRING[26] INPUT
DEF INT LISTIDX
INPUT = "/_N_MPF_DIR/_N_EXECUTE_MPF"
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)
1.9.7

Selection of a substring (SUBSTR)

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.
Syntax
STRING_ERG = SUBSTR (STRING,INT)
STRING_ERG = SUBSTR(STRING,INT, INT)
Semantics
In the first case, the substring from the position specified by the second parameter is
returned up to the end of the string.
In the second case, the result string is limited to the maximum length, specified by the third
parameter.
If the initial position is after the end of the string, the empty string (" ") will be returned.
If the initial position or the length is negative, an alarm is output.
82
Comments
;
The value returned in LISTIDX is 3;
because "N" is the fist character in the
parameter INPUT 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 in the components "path"
and "module":
;
Then returns "_N_MPF_DIR"
;
Then returns "_N_EXECUTE_MPF"
; Result type: INT
; Result type: INT
Programming Manual, 07/2010, 6FC5398-2BP40-0BA0
Job planning

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents