INDEXOF
Syntax
![]()
Command
Mandatory parameter Optional parameter Mandatory keyword Optional keyword |
<Result> := INDEXOF (<Search value>, <Source>[, <Start position>][, <Case sensitive>])
Description
Returns an Integer specifying the position of the first character of the first occurrence of <Search value> within <Source>. Optional a start position other than the beginning of <Source> can be specified and whether the search should be case sensitive.
Diagram
Returned value type
Integer
Parameters
Parameter | Description |
<Search value> | The value to search for in <Source> of type Alpha, String or Realstring |
<Source> | The source value to search in of type Alpha, String or Realstring. |
<Start position> | Optional start position for the search (defaults to 1) |
<Case sensitive> | When set to True, the search will be case sensitive. When False case insensitive. (defaults to True) |
Remarks
When <Search value> is not found zero will be returned. Zero will also be returned when <Start position> is greater than the length of <Source>, less or equal to zero or when <Search value> is an empty string/alpha.
Example
var
Str : String
Result : Integer
code
Str := 'This is an example text'
Result := Indexof ('an', Str) // Result = 9
Result := Indexof ('nonexisting', Str) // Result = 0
Result := Indexof ('e', Str) // Result = 12
Result := Indexof ('e', Str, 1) // Result = 12
Result := Indexof ('e', Str, 13) // Result = 18
Result := Indexof ('e', Str, 19) // Result = 21
Result := Indexof ('e', Str, 22) // Result = 0
Result := Indexof ('E', Str, 19) // Result = 0
Result := Indexof ('E', Str, 19, FALSE) // Result = 21
Str : String
Result : Integer
code
Str := 'This is an example text'
Result := Indexof ('an', Str) // Result = 9
Result := Indexof ('nonexisting', Str) // Result = 0
Result := Indexof ('e', Str) // Result = 12
Result := Indexof ('e', Str, 1) // Result = 12
Result := Indexof ('e', Str, 13) // Result = 18
Result := Indexof ('e', Str, 19) // Result = 21
Result := Indexof ('e', Str, 22) // Result = 0
Result := Indexof ('E', Str, 19) // Result = 0
Result := Indexof ('E', Str, 19, FALSE) // Result = 21