READ and READLN procedures

Language reference ›› Built-in procedures ›› "console" procedures ››
Parent Previous Next

read-procedure = READ "(" variable { "," variable } ")" .
readln-procedure = READLN { "(" variable { "," variable } ")" } .

This is the standard Pascal READ and READLN procedures that read variables from the current console (see ASSIGN).


May be any simple variable of type BYTE, CHAR, SHORTINT, INTEGER, WORD, LONGINT, LONGWORD, STRING.

CHAR variables may be READ individually, they are not treated as BYTE in this case.

PMP specificities:

There is no buffer. If a numeric is followed by a space or tabulation character, this one will be lost for the next READ (see example below).

REAL numbers are not allowed.

 B: byte; C: char; S: string;

 // Assuming that incoming characters are '*  123  ABCD’
 READLN(C, B, S); // This will set C to '*’, B to 123 and S to ' ABCD'
                  // (note that one space before ABCD has been lost)