---
url: >-
  /statelake/scripting-reference/functions-and-procedures/string-functions/indexstr.md
---

# IndexStr

**IndexStr** is a case sensitive function, that determines if any of the strings that are contained in the array **AValues** match the string specified by **AText**.

Using a case sensitive comparison, the function returns a zero-based index response where the first match in the array is number zero (**0**), the second match one (**1**) etc., and returns minus one (-1) if no match is found.

**Declaration**: Function IndexStr(const AText : string; const AValues : array of string) : Integer;

Examples follow using a simple array, showing the case sensitivity.

```pascal
procedure ScriptEvent(var Value:Variant);
var
  Str1, Str2 : string;
  Int1, Int2 : integer;
begin

  Str1 := 'Ken';
  Str2 := 'ken';

  Int1 := IndexStr(Str2, ['joe', 'ken', 'fred', 'josh']);
  LogInfo(Str2+' is in position # '+IntToStr(Int1));
 If Int1 = -1 then //Matches  ken to ken
   LogInfo('The string is not present.')
 else
   LogInfo('The string is present.');

  Int2 := IndexStr(Str1, ['joe', 'ken', 'fred', 'josh']);
  LogInfo(Str1+' is in position # '+IntToStr(Int2));

 If Int2 = -1 then //Does not match  Ken to ken
   LogInfo('The string is not present.')
 else
    LogInfo('The string is present.');

end;
```

This code writes to the log as illustrated below.

For a function performing the same role that is not case sensitive, please review [IndexText](/statelake/scripting-reference/functions-and-procedures/string-functions/indextext).
