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: Searches for the character specified as second parameter (from the beginning) in the
first parameter.
RINDEX: Searches for the character specified as second parameter (from the end) in the first
parameter.
MINDEX: 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.
MATCH: Searches for a string in a string.
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 Comment
DEF INT PFADIDX, PROGIDX
DEF STRING[26] INPUT
DEF INT LISTIDX
INPUT = "/_N_MPF_DIR/_N_EXECUTE_MPF"
Work preparation
3.1 Flexible NC programming
NC programming
452 Programming Manual, 12/2019, 6FC5398-2EP40-0BA0