home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume2 / pstrings / part01 / mkStaticS.p < prev    next >
Encoding:
Text File  |  1991-08-07  |  539 b   |  27 lines

  1.  
  2.  
  3.  
  4.  
  5. # include "strings.h"
  6.  
  7. procedure mkStaticS{(s: String; var p: packed array[lo..hi:Integer] of Char)};
  8. {
  9. * Converts a dynamic string into a static string.
  10. * p is null padded if necessary.
  11. * Info will be lost if lengthS(s) > hi-lo+1.
  12. }
  13.    var i: Integer; j: Nat1; lens: Nat0; ch,null: Char; sp: CharOfString;
  14. begin
  15.     j := 1; lens := lengthS(s);  null := chr(0);
  16.     if lens <> 0 then
  17.       first(sp, s);
  18.     for i := lo to hi do
  19.       if j <= lens then begin
  20.         next(sp, ch);
  21.         p[i] := ch;
  22.         j := j+1
  23.       end
  24.       else
  25.         p[i] := null
  26. end{ -- mkStaticS};
  27.