User guide

78 CHAPTER 3. THE LIBRARY
returns TRUE if successful, and FALSE otherwise. A call of unrdch will alway s succeeds
the first time after a call of rdch. It is useful in functions such as readn where singl e
character lookahead is necessary. See Section 3.3.1 for more detailed information.
wrch(ch) CIN:y, POS:y, NAT:y
This routine wri t e s the character ch to the currently selected output stream. If
output is to the screen, ch is transmitted immediately. It aborts (with code 189) if
there is a write failure.
writed(n, d) CIN:y, POS:y, NAT:y
writeu(n, d) CIN:y, POS:y, NAT:y
writen(n) CIN:y, POS:y, NAT:y
These rout i ne s output the integer n in decimal to the currently selected output
stream. For writed and writeu, the output is padded with leading spaces to fill a field
width of d characters. If writen is used or if d is to o small , the number is written
without padding. If writeu is used, n is regarded as an unsigned integer.
writehex(n, d) CIN:y, POS:y, NAT:y
writeoct(n, d) CIN:y, POS:y, NAT:y
writebin(n, d) CIN:y, POS:y, NAT:y
These routines output, repectively, the least significant d hexadeci mal , octal or
binary digits of the integer n to the currently selected output st re am.
writes(str) CIN:y, POS:y, NAT:y
writet(str, d) CIN:y, POS:y, NAT:y
These routines out put the string str to the curr e ntly selected output stream. If
writet is use d, trailing spaces are added to fill a field width of d characters.
writef(format,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z)
CIN:y, POS:y, NAT:y
The fir st argument (format) is a string that is c opi ed character by character to
the currently selected output stream until a substitution item such as %s or %i5 is
encountered when a value (usually the ne x t argument) is output in the specified format.
The substitution items are given in table 3.6.
When a fiel d width (denoted by n in the table) is r e q ui r ed , it is specified by a
single character, with 0 to 9 being represented by the corresponding digit and 10 to
35 represented by the letter s A to Z. Format characters are case insensitive but field
width characters are not. A recent entension allows the field width to be specified as a
decimal integer immediately following the percent, as in %12i meaning %iB.
Some examples of the %n.md substitution item are given below.
writef("%9.2d", 1234567) writes 12345.67
writef("%9.2d", -1234567) writes -12345.67
writef("%9.0d", 1234567) writes 1234567
writef("%9d", 1234567) writes 1234567
As an e x ampl e of how the %p substitution it em can be used, the following code: