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

  1.  
  2.  
  3.  
  4.  
  5. # include "strings.h"
  6.  
  7. procedure next{(var c: CharOfString; var ch: Char)};
  8. {
  9. * c is advanced to point to next char in its string and current char
  10. * returned in ch
  11. *
  12. * precondition
  13. *     c initialised by call to first and not at end of string
  14. }
  15.   var nxtchunk: stringtail;
  16. begin
  17.     with c do
  18.      case KIND of
  19.       true: begin { -- header record }
  20.          ch := HD^.HEAD[POS];
  21.          if POS <> slength then
  22.             POS := POS+1
  23.          else begin
  24.             POS := 1;
  25.             nxtchunk := HD^.TAIL;
  26.             { -- change variant }
  27.             KIND := false;
  28.             TL := nxtchunk
  29.          end
  30.         end;
  31.       false: begin { -- tail record }
  32.           ch := TL^.MORE[POS];
  33.           if POS <> slength then
  34.             POS := POS+1
  35.           else begin
  36.             POS := 1;
  37.             TL := TL^.REST
  38.           end
  39.          end
  40.      end{ -- case}
  41. end;
  42.