Search For Character/String In The String (Index, Rindex, Mindex, Match) - Siemens SINUMERIK 840D sl Programming Manual

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

Advertisement

Work preparation
3.1 Flexible NC programming
Example
In conjunction with the single character access, this function allows the end of a character string
to be determined:
Program code
IF (STRLEN(BLOCK_NAME)>10) GOTOF ERROR
3.1.4.6

Search for character/string in the string (INDEX, RINDEX, MINDEX, MATCH)

This functionality searches for single characters or a string within a string. The function results
specify where the character/string is positioned in the string that has been searched.
Syntax
INT_RES=INDEX(STRING,CHAR) ; Result type: INT
INT_RES=RINDEX(STRING,CHAR) ; Result type: INT
INT_RES=MINDEX(STRING,STRING) ; Result type: INT
INT_RES=MINDEX(STRING,STRING) ; Result type: INT
Semantics
Search functions: It supplies the position in the string (first parameter) where the search has
been successful. If the character/string cannot be found, then the value -1 is returned. The first
character has position 0.
Meaning
INDEX:
RINDEX:
MINDEX:
MATCH:
This allows strings to be broken up according to certain criteria, for example, at positions with
blanks or path separators ("/").
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"
452
Searches for the character specified as second parameter (from the beginning) in the
first parameter.
Searches for the character specified as second parameter (from the end) in the first
parameter.
Corresponds to the INDEX function, except for the case that a list of characters is
transferred (as string) in which the index of the first found character is returned.
Searches for a string in a string.
Comment
Programming Manual, 12/2019, 6FC5398-2EP40-0BA0
NC programming

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sinumerik 840de sl

Table of Contents