[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'System' (#rtl)

Write

Write variable to a text file or standard output

Declaration

Source position: system.fpd line 68

procedure Write(

  V1: Type1

);

procedure Write(

  V1: Type1;

  V2: type2

);

procedure Write(

  V1: Type1;

  V2: Type2;

  V3: Type3

);

procedure Write(

  var F: Text;

  V1: Type1

);

procedure Write(

  var F: Text;

  V1: Type1;

  V2: type2

);

procedure Write(

  var F: Text;

  V1: Type1;

  V2: Type2;

  V3: Type3

);

Description

Write writes the contents of the variables V1, V2, V3 etc. to the file F. F can be a typed file, or a Text file. If F is a typed file, then the variables V1, V2 etc. must be of the same type as the type in the declaration of F. Untyped files are not allowed.

The Write command accepts an arbitrary number of arguments. The V1, V2, V3 in the declaration here are in fact just samples, the actual number may be much higher. The types of arguments (Type1 etc.) are limited to the following types:

If the parameter F is omitted, standard output is assumed. If F is of type Text, then the necessary conversions are done such that the output of the variables is in human-readable format. This conversion is done for all numerical types. Strings are printed exactly as they are in memory, as well as PChar types.

The format of the numerical conversions can be influenced through the following modifiers: OutputVariable: NumChars [: Decimals ] This will print the value of OutputVariable with a minimum of NumChars characters, from which Decimals are reserved for the decimals. If the number cannot be represented with NumChars characters, NumChars will be increased, until the representation fits. If the representation requires less than NumChars characters then the output is filled up with spaces, to the left of the generated string, thus resulting in a right-aligned representation. If no formatting is specified, then the number is written using its natural length, with nothing in front of it if it's positive, and a minus sign if it's negative. Real numbers are, by default, written in scientific notation.

Remark: When writing string variables, no codepage conversions are done. The string is copied as-is to the file descriptor. In particular, for console output, it is the programmer's responsibility to make sure that the codepage of the string matches the codepage of the console.
Remark: Note that on MS Windows GUI applications do not have a standard output by default: Standard file descriptors are available only when the
{$APPPTYPE CONSOLE}

Errors

If an error occurs, a run-time error is generated. This behavior can be controlled with the {$I} switch.

See also

WriteLn

  

Write variable to a text file or standard output and append newline

Read

  

Read from a text file into variable

Readln

  

Read from a text file into variable and goto next line

Blockwrite

  

Write data from memory to an untyped file


Documentation generated on: May 14 2021