home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol023 / depad.lib < prev    next >
Text File  |  1984-04-29  |  602b  |  33 lines

  1.  
  2. {    DEPAD
  3.  
  4.     Takes a string which has been padded with spaces and returns
  5.     a copy shortened by dropping the trailing spaces.
  6.  
  7.     The following global declarations are required:
  8.         TYPE    string255 = string 255;
  9.         PROCEDURE setlength;
  10.         PROCEDURE length;
  11. }
  12.     
  13. FUNCTION depad (str : string255) : string255;
  14.  
  15. VAR    done : boolean;
  16.     loc : byte;
  17.     temp : string255;
  18.  
  19. begin
  20.     done := false;
  21.     setlength (temp,0);
  22.     append (temp,str);
  23.     loc := length(temp);
  24.     repeat
  25.         if (temp[loc] = ' ')
  26.             then loc := pred(loc)
  27.             else done := true
  28.     until done;
  29.     setlength (temp,loc);
  30.     depad := temp
  31. end;
  32.  
  33.