PROGRAM testinput; (* handle Turbo console input in a reasonable manner, without *) (* having any input^, and all the other silly deviations from *) (* the Pascal standard. The replacement procedures do it. *) VAR lgh, ii : integer; int : integer; strng : string[128]; (* set to match inmax, in inprims *) rr : real; (* 1---------------1 *) (*$i kbdprims.trb *) (* fundamental primitives, kbd file *) (* 1---------------1 *) (*$i inprims.trb *) (* char/integer primitives for input file *) (* 1---------------1 *) (*$i inprimsr.trb *) (* real primitives for input file *) (* 1---------------1 *) BEGIN (* testin *) writeln('EOF (=CTL-Z) only valid immediately after EOLN'); writeln('EOF exits each test section'); writeln('(Many screens will clear on other CTL-Zs)'); writeln; writeln('Testing KBD primitives'); REPEAT IF kbdpts IN [' '..'~'] THEN write(' ''', kbdpts, ''''); write(ord(kbdpts) : 4); IF eolnkbd THEN write(' EOLN'); IF eofkbd THEN write(' EOF') ELSE getkbd; writeln; UNTIL eofkbd; getkbd; (* do an auto-reset after eof *) writeln('Now a standard copying routine, KBD to console'); WHILE NOT eofkbd DO BEGIN WHILE NOT eolnkbd DO BEGIN (* readkbd(ch); write(ch); *) (* use whichever you prefer *) write(kbdpts); getkbd; END; readlnkbd; writeln; END; getkbd; (* do an auto-reset after eof *) writeln; writeln('End of KBD tests, testing INPUT file, always buffered'); writeln; writeln('Testing input get/eof/eoln/read'); WHILE NOT eofin DO BEGIN WHILE NOT eolnin DO BEGIN write(inpts); getin; END; readlnin; writeln; END; getin; (* do an auto-reset after eof *) writeln('Testing integer reads'); WHILE NOT eofin DO BEGIN readini(int); writeln(int : 1); WHILE inpts = ' ' DO getin; (* So eof is detected correctly *) END; getin; (* auto-reset *) writeln('Testing read into Turbo strings'); WHILE NOT eofin DO BEGIN rdsin(strng); readlnin; writeln(strng); END; getin; (* auto-reset *) writeln('Testing real variable reads'); WHILE NOT eofin DO BEGIN readinr(rr); writeln(rr); WHILE inpts = ' ' DO getin; (* So eof is detected correctly *) END; getin; (* auto-reset *) (* NOTE: If executed and re-executed in memory, i.e. no COM file, *) (* the internal flags are not left in their initial state, and the *) (* re-execution will have some minor anomalies. *) END. (* testin *)