home *** CD-ROM | disk | FTP | other *** search
- unit Strutils;
-
- { Program copyright (c) 1995 by Charles Calvert }
- { Project Name: EXPLORER }
-
- interface
-
- function LeftSet(src: String; Width: Integer; var Trunc: Boolean): String;
- function GetFirstWord(S : String) : String;
- function StripSpaces(S : String) : String;
- function AddBackSlash(S: String): String;
-
- implementation
-
- uses SysUtils;
-
- function LeftSet(src: String; Width: Integer; var Trunc: Boolean): String;
- { Pads a string on the left }
- var
- I : Integer;
- begin
- Trunc := False;
- Result := src;
- if(Length(Result) > Width) and (Width > 0) then begin
- Result[0] := CHR(Width);
- Trunc := True;
- end
- else
- for i := Length(Result) to width do
- Result := Result + ' ';
- end;
-
- function GetFirstWord(S : String) : String;
- { Returns the first word from a string }
- Var
- i : Integer;
- begin
- i := 1;
- Result := S;
- while (Result[i] <> ' ') and (i < Length(S)) do begin
- Result[i] := S[i];
- Inc(i);
- end;
- Dec(i);
- Result[0] := Chr(i);
- end;
-
- function AddBackSlash(S: String): String;
- begin
- Result := S;
- if S[Length(S)] <> '\' then
- AppendStr(Result, '\');
- end;
-
- function StripSpaces(S: String): String;
- { Strips all spaces out of a string }
- var
- i: Integer;
- begin
- i := 1;
- repeat
- if S[i] = ' ' then
- Delete(S, i, 1)
- else
- inc(i);
- until i > Length(S);
- Result := S;
- end;
-
- end.
-