Name
Write Procedure
Syntax
procedure Write(var F: File; var Value; ...); procedure Write(Expr
:Width
:Precision
; ...); procedure Write(var F: TextFile;Expr
:Width
:Precision
; ...);
Description
The Write
procedure writes text or other values to
a file. If you are writing to a binary file, you must supply a
variable of the same type as the file’s base type. You can
write multiple records by listing multiple variables as arguments to
the Write
procedure.
When writing to a TextFile
, you can write strings,
numbers, characters, and Boolean values. Each value can be followed
by the Width
and
Precision
expressions, separated by
colons. Width
and
Precision
can be any integer expressions.
Width
specifies the minimum size of the
string representation of Expr
, and
Precision
specifies the number of places
after the decimal point of a floating-point number.
Write
uses as many characters as it needs, so
Width
is just the suggested minimum width.
If the number requires fewer than Width
characters, Write
pads the string on the left with
blanks. If you do not supply a Width
,
Delphi uses 1 as the minimum width for integers and it prints
floating-point numbers as 26 characters in the following form:
'-1.12345678901234567E+1234'
If Expr
is a floating-point number,
Write
reduces the number of decimal places to fit
the value into a string that uses at most
Width
characters. Write
always uses at least one digit after the decimal place, though. You
can also supply a Precision
, which tells
Write
how many decimal ...
Get Delphi in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.