home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TPTOOL5.ZIP / STRIPSPC.INC < prev    next >
Encoding:
Text File  |  1987-03-27  |  791 b   |  41 lines

  1.  
  2. #log Strip leading or trailing spaces 1.0
  3.  
  4. (*------------------------------------------
  5.  *
  6.  * strip_leading_spaces
  7.  *    remove all leading spaces from a string
  8.  *
  9.  *)
  10.  
  11. procedure strip_leading_spaces(var str: anystring);
  12. var                           
  13.    p: integer;
  14.  
  15. begin
  16.    p := 1;
  17.    while (str[p] = ' ') and (p < ord(str[0])) do
  18.       p := succ(p);
  19.  
  20.    if p > 1 then
  21.       delete(str,1,p-1);
  22. end;
  23.  
  24.  
  25. (*------------------------------------------
  26.  *
  27.  * strip_trailing_spaces
  28.  *    remove all text after the first space in a string
  29.  *
  30.  *)
  31.  
  32. procedure strip_trailing_spaces(var str: anystring);
  33. var
  34.    posit:  integer;
  35. begin
  36.    posit := pos(' ',str);
  37.    if posit > 0 then
  38.       str[0] := chr(posit-1);     {remove trailing spaces and comments}
  39. end;
  40.  
  41.