MatchText
The function MatchText determines if any of the strings that can be found in the array AValues match the string that has been specified by AText, using a case insensitive comparison.
It returns the boolean value of True if at least one of the strings in the array match, or False if none of the strings match.
For a case sensitive comparison, use the MatchStr routine.
Declaration: Function MatchText(const AText : string; const AValues : array of string) : Boolean;
An example follows.
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 := MatchText(Str1, [
'black'
,
'blue'
,
'white'
,
'brown'
,
'pink'
]);
//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(
''
);
ConfYN := MatchText(Str1, [
'black'
,
'blue'
,
'white'
,
'brown'
,
'pink'
,
'YELLOW'
]);
//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(
''
);
//Is 'BLue' in there?
ConfYN := MatchText(Str2, [
'black'
,
'blue'
,
'white'
,
'brown'
,
'pink'
]);
//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(
''
);
ConfYN := MatchText(Str2, [
'black'
,
'blu'
,
'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(
''
);
end
;