SmartPascal
TrimLeft
Function
Removes leading blanks from a string SysUtils unit
1  function TrimLeft ( const Text : String ) : String;
2  function TrimLeft ( const Text : WideString ) : WideString;
Description
The TrimLeft function removes blank and control characters (such as line feed) from the start of a string.
Related commands
Delete Delete a section of characters from a string
AnsiMidStr Returns a substring from the middle characters of a string
AnsiLeftStr Extracts characters from the left of a string
AnsiRightStr Extracts characters from the right of a string
Trim Removes leading and trailing blanks from a string
TrimRight Removes trailing blanks from a string
 
Example code : Illustrating Trim, TrimLeft and TrimRight
// 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
  SysUtils,   // Unit containing the TrimLeft 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);

const
  PaddedString = '  Letters     ';
begin
  ShowMessage('[' + TrimLeft(PaddedString)  + ']');
  ShowMessage('[' + TrimRight(PaddedString) + ']');
  ShowMessage('[' + Trim(PaddedString)      + ']');
end;
 
end.
Hide full unit code
   [Letters     ]
   [  Letters]
   [Letters]