User guide
Chapter 5
Console Input and Output
When cintsys or cintpos is started a stream i s opened to recei ve input from standard
input which is normally the keyboard and a second stream is opened to allow output
to standard output which is normally the screen. This combination of keyboard and
screen is called the console. The treatment of console streams depends on whether
cintsys or cintpos is being used.
5.1 Cintsys console strea ms
The stream control block for the keyboard is obtained by calling findinput("**").
The stream is created the first time it is called. Subsequent calls yi el d exactly the same
stream control block . This stream has a buffer large enough to hold 4096 characters.
Characters are read from the keyboard using sardch which reads and e cho e s each
character to the screen. Exceptionally, ctrl-c (code 3) causes a SIGINT interrupt,
RUBOUT (code 127) is transl at ed to backspace (code 8), ctrl-j, ctrl-m and the ENTER
(or RETURN) key all yield code 10 (the B CPL newline character) but they all echo
carriage return and linefeed to the screen.
Simple line editin g of keyboard inpu t is performed as follows. As characters are
typed they are normally transferred into t he buffer, but if a backspace is received, the
latest character, is any, in the buffer is remove d and its echoed symbol removed from
the screen. The contents of the buffer is not made available to the user until e i th er a
newline character is received or t he buffer becomes ful l .
A user can receive keyboard characters as soon as they are typed using calls of
sardch.
The stream control block for the screen is obtained by calling findoutput("**").
The stream is created the first time it is called. Subsequent calls yi el d exactly the same
stream control block . This stream has a buffer large enough to hold 4096 characters.
Call of wrch plac es characters in this buffer, and when a newline or newpage character
is wr i tt en , or the buffer becomes full, or a call of deplete is made, the contents of the
buffer is transmitted to the screen by calls of sawrch.
The program BCPL/bcplprogs/test/inputtst.b can be used to demonstate some
of the features of console input.
131