This page is intended as a supplement to the official documentation on Delphi programming. CodeGear is in the process of putting the Delphi documentation on the Web. Once they have done so, this page will link to the relevant page in the official documentation.
This article is a stub.
Please help enhance the Delphi Programming Wiki by expanding it.
see the VCL Documentation Guidelines for an overview on doc pages



  function RightStr(const AText: AnsiString; const ACount: Integer): AnsiString; overload;
  function RightStr(const AText: WideString; const ACount: Integer): WideString; overload;

The RightStr function takes 2 parameters. The first parameter is the source string and the second is an index integer which counts backwards from the end of the string.

The result is a substring at the very end of the source string with the length given in the second parameter.

Technical CommentsEdit

(Known issues / Documentation clarifications / Things to be aware of)


  SourceString, SubString: String;
  SubStringLength: Integer;
  SourceString := 'Delphi Wikia'; //string length is 12
  SubStringLength := 5;
  SubString := RightStr(SourceString, SubStringLength);
  ShowMessage(SubString); //will show 'Wikia'
  SubStringLength := 20; //length is more then the source string
  SubString := RightStr(SourceString, SubStringLength);
  ShowMessage(SubString); //will show the complete SourceString 'Delphi Wikia'

  SubStringLength := -1; 
  SubString := RightStr(SourceString, SubStringLength);
  ShowMessage(SubString); //If the SubStringLength is anything lower than 1 then then result will be empty

See AlsoEdit

(Please provide links to items specifically related to this item.)

User Comments/TipsEdit

(Please leave your name with your comment.)

Community content is available under CC-BY-SA unless otherwise noted.