home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pctchnqs / 1991 / number5 / parse.pas < prev    next >
Pascal/Delphi Source File  |  1991-09-18  |  988b  |  34 lines

  1. { A program demonstrating Turbo Pascal 5.5's built in parsing             }
  2. {   Program parses a line and displays the individual words on seperate   }
  3. {   lines on the screen.                                                  }
  4. {$M 1024,0,0}
  5. {$A-,E-,L-,N-,R- }
  6. PROGRAM PARSE;
  7.  
  8. USES CRT;
  9.  
  10. CONST 
  11.   MESSAGE =
  12.     'Now is the time for all good men to code in 68-char columns.';
  13.  
  14. TYPE
  15.   PSTRING     = STRING[128]; { Defines biggest parsable string  }
  16.   PPS         = ^PSTRING;    { This will point at Prog. Prefix  }
  17.  
  18. VAR
  19.   PARSELINE   : PPS;
  20.   X           : INTEGER;
  21.   WORKSTR     : STRING[40];
  22.  
  23. BEGIN
  24.   PARSELINE := PTR(PREFIXSEG,128); { Initialize pointer to work area  }
  25.   CLRSCR;
  26.   WRITELN('MESSAGE: ',MESSAGE);    { Show what is going to be parsed  }
  27.   PARSELINE^ := MESSAGE;
  28.   FOR X := 1 TO PARAMCOUNT DO      { Now display each of the pieces   }
  29.     WRITELN(PARAMSTR(X));
  30.   READLN;                          { Let user acknowledge the display }
  31. END.
  32.  
  33.  
  34.