Skip to content

MatchStr ​

The MatchStr function works in a similar way to the MatchText function.

MatchStr determines if any of the strings in the specified array AValues match the string specified by AText using a case sensitive comparison.

It returns the boolean value of True if at least one of the strings in the array matches, or returns False if none of the strings match.

For a case insensitive match, use the routine MatchText.

Declaration: Function MatchStr(const AText : string; const AValues : array of string) : Boolean;

pascal
procedure ScriptEvent (var Value : variant);
var
  Str1, Str2 : string;
  ConfYN : boolean;
  iNum : integer;
begin
  Str1 := 'yellow';
  Str2 := 'BLue';
  iNum := 1;

 //Is 'yellow' in there?
  ConfYN := MatchStr(Str1, ['black', 'blue', 'yellow', 'white', 'brown','pink']);    //Result is TRUE
  If ConfYN = true then
    LogInfo('Yes. The colour '+Str1+' is in the array.')
 else
    LogInfo('No. The colour '+Str1+' is NOT in the array.');
  LogInfo('');
  ConfYN := MatchStr(Str1, ['black', 'blue', 'white', 'brown','pink','YELLOW']);     //Result is FALSE
  If ConfYN = true then
    LogInfo('Yes. The colour '+Str1+' is in the array.')
 else
    LogInfo('No. The colour '+Str1+' is NOT in the array.');
  LogInfo('');

 //Is 'BLue' in there?
  ConfYN := MatchStr(Str2, ['black', 'blue', 'white', 'brown','pink']);            //Result is FALSE
  If ConfYN = true then
    LogInfo('Yes. The colour '+Str2+' is in the array.')
 else
    LogInfo('No. The colour '+Str2+' is NOT in the array.');
  LogInfo('');
  ConfYN := MatchStr(Str2, ['black', 'BLUE', 'white', 'brown','pink','YELLOW']);   //Result is FALSE
  If ConfYN = true then
    LogInfo('Yes. The colour '+Str2+' is in the array.')
 else
    LogInfo('No. The colour '+Str2+' is NOT in the array.');
  LogInfo('');
  ConfYN := MatchStr(Str2, ['black', 'BLue', 'white', 'brown','pink','YELLOW']);   //Result is TRUE
  If ConfYN = true then
    LogInfo('Yes. The colour '+Str2+' is in the array.')
 else
    LogInfo('No. The colour '+Str2+' is NOT in the array.');
  LogInfo('');

end;