Content deleted Content added
Samiam95124 (talk | contribs) |
Samiam95124 (talk | contribs) →File type: Clarified the file example and removed reference to strings (which have nothing to do with files). |
||
Line 283:
===File type===
As shown in the example above, Pascal [[Computer file|files]] are sequences of components. Every file has a buffer variable which is denoted by ''f^''. The procedures ''get'' (for reading) and ''put'' (for writing) move the buffer variable to the next element. Read is introduced such that ''read(f, x)'' is the same as ''x := f^; get(f);''. Write is introduced such that ''write(f, x)'' is the same as ''f^ := x; put(f);'' The type {{code|text}} is predefined as file of char. While the buffer variable could be used for inspecting the next character to be used (check for a digit before reading an integer), this leads to serious problems with interactive programs in early implementations, but was solved later with the "lazy I/O" concept.▼
:<syntaxhighlight lang="pascal">
type
a = file of integer;
b = record
x : integer;
y : char
end;
c = file of b;
</syntaxhighlight>
▲As shown in the example above, Pascal [[Computer file|files]] are sequences of components. Every file has a buffer variable which is denoted by ''f^''. The procedures ''get'' (for reading) and ''put'' (for writing) move the buffer variable to the next element. Read is introduced such that ''read(f, x)'' is the same as ''x := f^; get(f);''. Write is introduced such that ''write(f, x)'' is the same as ''f^ := x; put(f);'' The type {{code|text}} is predefined as file of char. While the buffer variable could be used for inspecting the next character to be used (check for a digit before reading an integer), this leads to serious problems with interactive programs in early implementations, but was solved later with the "lazy I/O" concept.
===Pointer types===
|