Sunday, May 3, 2020

PARSED.P

[Table of Contents]

PARSED.P is a demo program from the Kyan Pascal 2.x Utilities Disk 2.

Source Code


PROGRAM PARSE_DEMO;

(* INPUT BUFFER PARSE ROUTINE

   COPYRIGHT (C) 1986 BY
   KYAN SOFTWARE, INC.  *)

TYPE
#I PARSET.I

VAR
   ARGCOUNT:INTEGER;
   BASE:STRPOINTER;

#I PARSELN.I

PROCEDURE PRINTBUFFER;
VAR WALKER:STRPOINTER;
BEGIN
   WALKER:=BASE;
   WHILE WALKER<>NIL DO
   BEGIN
      WRITELN(WALKER^.STRFOUND);
      WALKER:=WALKER^.NEXTSTR
   END
END;

FUNCTION COUNTINPUT:INTEGER;
VAR WALKER:STRPOINTER;
    I:INTEGER;
BEGIN
   I:=0;
   BASE:=PARSELINE;
   WALKER:=BASE;
   WHILE WALKER<>NIL DO
   BEGIN
      I:=I+1;
      WALKER:=WALKER^.NEXTSTR
   END;
   COUNTINPUT:=I
END;

PROCEDURE INIT;
BEGIN
   ARGCOUNT:=COUNTINPUT;
   WRITELN; WRITELN;
   WRITELN('*** PARSE DEMO ***');
   WRITELN;
   WRITELN('THE PARSE ROUTINE PROVIDES YOU');
   WRITELN('WITH AN EASY WAY TO WRITE KIX-LIKE');
   WRITELN('PASCAL PROGRAMS IN THAT YOU CAN');
   WRITELN('HAVE A USER TYPE PARAMETERS');
   WRITELN('DIRECTLY AFTER THE NAME OF THE');
   WRITELN('PROGRAM AT THE KIX COMMAND');
   WRITELN('PROMPT.  FOR EXAMPLE: WHEN');
   WRITELN('YOU CALLED THIS PROGRAM, YOU');
   WRITELN('TYPED ',ARGCOUNT:1,' WORDS:');
   PRINTBUFFER
END;

BEGIN
   INIT;
   WRITELN('TRY RUNNING THIS DEMO AGAIN WITH');
   WRITELN('MORE PARAMETERS ON THE COMMAND');
   WRITELN('LINE AFTER THE "PARSE.DEMO".');
   WRITELN;
   WRITE('PRESS RETURN...');
   READLN;
   WRITELN('THE PARSELINE ROUTINE CAN BE USED');
   WRITELN('AT ANY TIME IN A PROGRAM TO PARSE');
   WRITELN('THE CONTENTS OF THE INPUT BUFFER.');
   WRITELN;
   WRITE('FOR EXAMPLE:  '); READLN;
   ARGCOUNT:=COUNTINPUT;
   WRITELN(ARGCOUNT,' WORDS TYPED: ');
   PRINTBUFFER
END.

No comments:

Post a Comment