Janilabo

Janilabo | TrimStart() [SCAR Divi]

Apr 28th, 2013
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.78 KB | None | 0 0
  1. {==============================================================================]  
  2.   Explanation: Trims the beginning of the str.                  
  3. [==============================================================================}
  4. function TrimStart(str: string): string;
  5. var
  6.   i, l: Integer;
  7. begin
  8.   if (str <> '') then
  9.   begin
  10.     l := Length(str);
  11.     for i := 1 to l do
  12.       if (str[i] <> ' ') then
  13.         Break;
  14.     Result := Copy(str, i, ((l + 1) - i));
  15.   end else
  16.     Result := '';
  17. end;
  18.  
  19. var
  20.   str: string;
  21.  
  22. begin
  23.   ClearDebug;
  24.   str := '   TEST   ';
  25.   WriteLn('STR length before TrimStart(): ' + IntToStr(Length(str)) + ' ("' + str + '").');
  26.   str := TrimStart(str);
  27.   WriteLn('STR length after TrimStart(): ' + IntToStr(Length(str)) + ' ("' + str + '").');
  28. end.
Advertisement
Add Comment
Please, Sign In to add comment