The function StartsStr determines whether the substring ASubText begins the string AText.

If ASubText matches the begining of AText, then the result is True, otherwise a False is returned.

This function does not require that ASubText matches the case found within AText.

For a vase sensitive function that performs the same role, please review the StartsStr routine.

Declaration: Function StartsText(const ASubText, AText : string) : Boolean;

Examples that also use the BoolToStr function are below. Please review BoolToStr for more information.

procedure OnMapEvent(var Value:Variant);
var
TheText, FullText, Which : string;
BoYN : boolean;
begin
FullText := 'The Archbishop of Canterbury was in attendance.';
 
TheText := 'The Archbishop';
BoYN := StartsText(TheText, FullText);
Which := BoolToStr(BoYN, true);
LogInfo(Which); //1st test is true
 
TheText := 'The';
BoYN := StartsText(TheText, FullText);
Which := BoolToStr(BoYN, true);
LogInfo(Which); //2nd test is true
 
TheText := 'the archbishop';
BoYN := StartsText(TheText, FullText);
Which := BoolToStr(BoYN, true);
LogInfo(Which); //3rd test is true - case does not matter
TheText := 'An Archbishop';
BoYN := StartsText(TheText, FullText);
Which := BoolToStr(BoYN, true);
LogInfo(Which); //4th test is false due to the word An
 
end;