AMT Help Files
homeLION Language ReferenceCommandsINDEXOF

INDEXOF

Syntax

<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

Return to

Commands

Contents

 Go to top