Page 143 - Standard Handbook Of Petroleum & Natural Gas Engineering
P. 143
128 Mathematics
READ(variab1e list);-Stores each item of data in a location indicated by the
variable associated with it
READLN(variab1e list);-Causes input control to shift to the next line when
the end of the variable list or line of input is reached
WRITE(variab1e list);-Can also output a character string by placing it,
enclosed by single quotes, inside the parentheses; a field (a format for output)
may be assigned to a data item as
WRITE(SUM:5);
or, in the case of a real number, as
WRITE(X: 10:2);
specifying the total width and also the number of decimal places. If no field is
specified, a default width is assumed.
WRITELN(variab1e list);-Output shifts to the next line when the output list
has been completed
Some examples of Input/Output statements are:
WRITE(1,X);
WRITELN('J = ', ABSU):6);
WRITE(X + Y5:2);
READLN(X,Y);
READ( A,B,C,D) ;
If no other files are specified for input or output in the program heading,
the default files or devices (usually the keyboard and the printer or the screen)
are used. If other (declared) files are to be used, they must be prepared (see file
handling statements) and then specified in the input/output statements, as follows
WRITE(filename, variable);
READ(filename, variable);
For example,
WRITE(PFILE,PRSSR(I));
READ(TEMP,TFCT);
For details on file pointers, buffer variables, and GET and PUT operations, see
one of the advanced Pascal texts listed in the references.
File-handling statements-Every file, except the INPUT and OUTPUT files,
must be defined in a VAR statement that gives its name and type, e.g.,
VAR
TEMP: FILE OF CHAR;
PRSSR: FILE OF REAL;
and must be prepared before data can be written to or read from that file.
REWRITE(fi1ename);-Produces an empty file, to which data can be
written, and

