OPTION (1) BC; TITLE GAME OF LIFE - I/O PROCEDURES FOR VT100 TERMINALS VERSION 1.1, 27-APR-88 ; LET ESC = 27; % Escape character for terminal control seqs % % Size of screen % LET LINES = 23; LET COLS = 80; % Clear screen (VT100) % ENT PROC CLEARSCREEN (); % output terminal control sequence % TWRT ("#ESC#[2J#VT#"); ENDPROC; % Disable reverse video % ENT PROC DISABLERV (); % output terminal control sequence % TWRT ("#ESC#[m"); ENDPROC; % Enable reverse video % ENT PROC ENABLERV (); % output terminal control sequence % TWRT ("#ESC#[7m"); ENDPROC; % Position cursor % ENT PROC FIXCURSOR (INT DOWN, ACROSS); % check that requested position is on the screen % % (illegal requests are ignored) % IF DOWN > 0 AND DOWN <= LINES AND ACROSS > 0 AND ACROSS <= COLS THEN % output terminal control sequence % OUT (ESC); OUT ('['); IWRT(DOWN); OUT (';'); IWRT(ACROSS); OUT ('f'); END; ENDPROC; % Output a prompt to the terminal and read in user's reply % % The reply is treated as a decimal integer number % ENT PROC GETINTEGER (RAB PROMPT) INT; INT RESULT; % output prompt text % TWRT (PROMPT); TWRT (" ? #VT#"); % get reply % RESULT := IREAD (); SKIPLINE (); % ignore any other characters input % RETURN (RESULT); ENDPROC; % Skip (i.e. ignore) any remaining input characters % PROC SKIPLINE(); WHILE TERMCH # NL DO TERMCH := IN (); REP; ENDPROC; % Output a prompt to the terminal and get a Yes/No reply from the user % ENT PROC YESNOQUESTION (RAB PROMPT) BOOLEAN; BOOLEAN RESULT:=UNKNOWN; % loop until we get a valid reply % WHILE RESULT = UNKNOWN DO BLOCK BYTE REPLY; % output prompt text % TWRT (PROMPT); TWRT (" ? #VT#"); % get reply % REPLY := IN (); TERMCH := IN (); % set end-if-input char for SKIPLINE % SKIPLINE (); % ignore any other characters input % % check reply % IF REPLY = 'Y' OR REPLY = 'y' THEN RESULT := TRUE; ELSEIF REPLY = 'N' OR REPLY = 'n' THEN RESULT := FALSE; END; ENDBLOCK; REP; RETURN (RESULT); ENDPROC;