WRITE and WRITELN procedures

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

write-procedure = WRITE "(" expression-item { "," expression-item } ")" .
writeln-procedure = WRITELN { "(" expression-item { "," expression-item } ")" } .
expression-item = expression [ ":" width-expression ] .

This is the standard Pascal WRITE and WRITELN procedures that convert an expression to a string and outputs it to the current console (see ASSIGN), with optional width qualifiers.


May be any expression (numeric, char or string) that may be evaluated by the compiler. Single CHAR may be used (they are not converted to BYTE in this case).


An optional qualifier (defaults to zero) which specifies the width in characters where the value will be right adjusted; it is evaluated as BYTE: if the evaluation gives a larger value, a byte truncation warning is issued. A zero value means no adjustment.

PMP specificities:

A BOOLEAN expression is written as a BYTE expression (0 or 1).

At the end WRITELN outputs a pair of CR/LF characters, a simple CR or a single LF, according to the $EOL directive.

 B: byte; C: char;

 WRITE('This is one:', 1 : 3);   // This will output 'This is one:  1'
 B := 3;
 WRITE('This is three:', B);     // This will output 'This is three:3'
 C := '?';
 WRITE('Somebody there', C : 2); // This will output 'Somebody there ?'
 WRITELN; // Output a single CR/LF