Could somebody explain this to me?? Many thanks, --Johan University of Antwerp, Belgium. Probeer eens het volgende op een invoerfiletje van twee integers achter elkaar, bijv.
Dit illustreerd het verschil tussen read en readline wel aardig. Om het nu precieser te stellen: read var1, var2, Staan er nog meer waardes achter, dan kunnen deze gewoon gelezen worden. Succes ermee, Evert. The standard quip applies. I'm having problems with my rot13, again. If you don't know how many data values exist on the input data line, you may want to use a Read loop to fetch all the data.
OTOH, you may wish to only read "n" items of whatever's there, in which case the Readln is used to force subsequent reading to start with a new data line. Readln gives you that control, whereas Read doesn't. My not too sure what the difference would be for getting input from the keyboard but there is a difference when it is used to reading a text file.
Hope his helps as simple as possible : ReadLn makes the cursor go down one line when you read the variable. Read keeps the cursor on that line. The simple explanation is: use READ for non-text data files - i. Beginner needs help The rules are those, you normally write literals of such types within your Standard Pascal source code. ReadLn will in contrast to read consume a trailing line feed. It is discarded and does not have any influence on how to save supplied data.
The read line ending is platform-independent. A line ending typical for Windows-platforms will be read and does not pose a problem, even if the program is run on Linux or any other platform. Functions like eoLn and readLn only work on such files. In consequence readLn can not be used on typed files file of recordType variables. Read and readLn have a major drawback in that they expect the user to supply data in a given order.
If users do not comply a run-time error will terminate the program. You usually want to design your error messages in a way the user is capable in correcting her behavior. When reading ordinal types one can make use of the val procedure. Beware, it is necessary to check, whether the end of file has been reached before attempting to read data.
The text file input may not be open.
0コメント