TOPS-20 PASCAL Language Manual - Bitsavers
TOPS-20 PASCAL Language Manual - Bitsavers
TOPS-20 PASCAL Language Manual - Bitsavers
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
INPUT AND OUTPUT<br />
For a variable of an enumerated type, <strong>PASCAL</strong> prints the constant<br />
identifier denoting the variable's value. Because <strong>PASCAL</strong> ignores any<br />
characters beyond the thirty-first in an identifier, only the first 31<br />
characters of a long identifier appear, for example:<br />
VAR Color :<br />
BEGIN<br />
WRITE ('M~ favorite color is ',Color:35);<br />
(Blue,Yellow,Black,Sli~htl~_Pale_Peach_Summer_Sun5et)~<br />
END;<br />
When the value of Color is Yellow, the following is printed:<br />
M~ favorite color is YELLOW<br />
When the value of Color is Slightly_Pale Peach Summer_Sunset, however,<br />
the following appears:<br />
My favorite color is<br />
Although the field width specified is wide enough for all 33<br />
characters in the identifier, <strong>PASCAL</strong> ignores the last two characters<br />
and prints two leading blanks. Note that constants of enumerated<br />
types are printed in all uppercase characters.<br />
If you open the predeclared file OUTPUT with the carriage control<br />
option LIST, <strong>PASCAL</strong> allows you to use the WRITE procedure to prompt<br />
for input at the terminal. Each time you read from INPUT, the system<br />
checks for any output in the terminal record buffer. If the buffer<br />
contains any characters, the system prints them at the terminal, but<br />
suppresses the carriage return at the end of the lin(~. The output<br />
text appears as a prompt, and you can type your input on the same<br />
line, for example:<br />
WRITE ('Name three presidents:');<br />
READ (Pres1, Pres2, Pres3);<br />
When <strong>PASCAL</strong> executes the READ procedure, it finds the output string<br />
waiting to be printed. <strong>PASCAL</strong> prints the prompt at the terminal,<br />
leaving the carriage just after the colon (:). You can then begin<br />
typing input on the same line as the prompt.<br />
Prompting works only for the predeclared files INPUT and OUTPUT. For<br />
any other files, no output is written until you fill the record buffer<br />
or start a new line.<br />
Example 1<br />
TYPE Strins = PACKED ARRAY [1 •• <strong>20</strong>] OF CHAR;<br />
VAR Names: FILE OF Strins;<br />
Pres String;<br />
BEGIN<br />
WRITE (Names, 'Millard Fillmore " Pres);<br />
END;<br />
7-24