Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
WRITE Statement
◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
Writes data to the screen or a sequential file.
WRITE [[#]filenumber%,] expressionlist
■ filenumber% The number of an open sequential file. If the file
number is omitted, WRITE writes to the screen.
■ expressionlist One or more variables or expressions, separated by
commas, whose values are written to the screen or
file.
■ WRITE inserts commas between items and quotation marks around strings
as they are written. WRITE writes values to a file in a form that can
be read by the INPUT statement.
Example:
CLS
OPEN "LIST" FOR OUTPUT AS #1
DO
INPUT " NAME: ", Name$
INPUT " AGE: ", Age$
WRITE #1, Name$, Age$
INPUT "Add another entry"; R$
LOOP WHILE UCASE$(R$) = "Y"
CLOSE #1
'Print the file to the screen.
OPEN "LIST" FOR INPUT AS #1
CLS
PRINT "Entries in file:": PRINT
DO WHILE NOT EOF(1)
INPUT #1, Rec1$, Rec2$ 'Read entries from file.
PRINT Rec1$, Rec2$ 'Print the entries on the screen.
LOOP
CLOSE #1
KILL "LIST"
See Also ◄INPUT, LINE INPUT► ◄OPEN► ◄PRINT, LPRINT►