QBasic 1.1: WRITE Statement

Syntax

WRITE [[#]filenumber%,] expressionlist

Description / Parameter(s)

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"