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

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

Advertisement

Flexible NC programming
1.9 String operations
Program code
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) ; Result type: INT
STRING_ERG = SUBSTR(STRING,INT, INT) ; Result type: 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.
Example
Program code
DEF STRING[29] ERG
ERG = SUBSTR ("ACK:10 to 99", 10, 2)
82
Comments
; 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"
Comments
; Therefore the following
applies: ERG == "10"
Programming Manual, 02/2011, 6FC5398-2BP40-1BA0
Job planning

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sinumerik 840de slSinumerik 828d

Table of Contents