Skip to content

EndsStr ​

Another case sensitive function, EndsStr determines whether the substring ASubText appears at the end of the string AText.

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

For a function that performs the same role but does not take case sensitivity into account, please review the EndsText routine.

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

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

pascal
procedure OnMapEvent(var Value:Variant);
var
  TheText, FullText, Which : string;
  BoYN : boolean;
begin
  FullText := 'The Archbishop of Canterbury was in attendance.';

  TheText := 'attendance.';
  BoYN := EndsStr(TheText, FullText);
  Which := BoolToStr(BoYN, true);
  LogInfo(Which);                        //1st test is true

  TheText := 'was in attendance.';
  BoYN := EndsStr(TheText, FullText);
  Which := BoolToStr(BoYN, true);
  LogInfo(Which);                        //2nd test is true

  TheText := 'Attendance.';
  BoYN := EndsStr(TheText, FullText);
  Which := BoolToStr(BoYN, true);
  LogInfo(Which);                        //3rd test is false due to case

  TheText := 'attendance';
  BoYN := EndsStr(TheText, FullText);
  Which := BoolToStr(BoYN, true);
  LogInfo(Which);                        //4th test is false due to no full-stop

  TheText := 'absent.';
  BoYN := EndsStr(TheText, FullText);
  Which := BoolToStr(BoYN, true);
  LogInfo(Which);                        //5th test is false due to ABSENT

end;