Skip to main content

StringIndex

Function StringIndex( const aString : String; const aCases : TStringArray; const aCaseSensitive : Boolean) : Integer

Example

procedure ScriptEvent(var Value: variant);
var
Cases: TStringArray;
begin
SetArrayLength(Cases, 2);
Cases[0] := 'Ready';
Cases[1] := 'Held';
Value := StringIndex('ready', Cases, True); // 0: True currently ignores case
end;

Usage

Use StringIndex to find the zero-based first whole-string match in a TStringArray; it returns -1 when no item matches.

Current Velox reverses the declared flag: pass True for case-insensitive matching and False for case-sensitive matching. Review affected scripts when this product defect is corrected; IndexText is the clearer choice for case-insensitive lookup.

Return value

  • 0..Length(aCases)-1 for the first complete-string match;
  • -1 for no match or an empty array.

Duplicate matching entries return the lowest index. Substrings do not match; both complete strings are compared.

Additional Technical Info

StringIndex returns the zero-based position of the first array element equal to aString, or -1 when no element matches. The current implementation reverses the meaning of aCaseSensitive.

The example is fictional and source-reviewed only. It deliberately demonstrates the flag defect.

Actual case behavior

aCaseSensitiveNative comparison usedActual behavior
TrueSameText(aString, aCases[i])Case-insensitive.
FalseSameStr(aString, aCases[i])Case-sensitive.

This is not only a documentation naming issue; the branches in the product source call the opposite helper.

Performance and concurrency

Elements are compared sequentially until a match. Runtime is proportional to the number and length of candidates. The function does not mutate the array or shared Velox state.

External references

Created 2026-07-15