DelphiBasics
AnsiRightStr
Function
Extracts characters from the right of a string StrUtils unit
 function AnsiRightStr ( const Source : AnsiString; const Count : Integer ) : AnsiString;
Description
The AnsiRightStr extracts characters from the right of a string.
 
It attempts to return the rightmost Count characters from Source.
 
If Count exceeds the size of the source, the whole of source is returned.
Related commands
AnsiLeftStr Extracts characters from the left of a string
AnsiMidStr Returns a substring from the middle characters of a string
Trim Removes leading and trailing blanks from a string
TrimLeft Removes leading blanks from a string
TrimRight Removes trailing blanks from a string
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 Download this web site as a Windows program.




 
Example code : A simple example
// Full Unit code.
// -----------------------------------------------------------
// You must store this code in a unit called Unit1 with a form
// called Form1 that has an OnCreate event called FormCreate.
 
unit Unit1;
 
interface
 
uses
  StrUtils,   // Unit containing the AnsiRightStr command
  Forms, Dialogs;
 
type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  end;
 
var
  
Form1: TForm1;
 
implementation
{$R *.dfm} // Include form definitions
 
procedure TForm1.FormCreate(Sender: TObject);

var
  source, target : AnsiString;
begin
  source := '123456789';
  target := AnsiRightStr(source, 3);

  ShowMessage('Source = '+source);
  ShowMessage('Target = '+target);
end;
 
end.
Hide full unit code
   Source = 123456789
   Target = 789
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Home Page