QBasic 1.1: PUT (File I/O) Statement

Syntax

GET [#]filenumber%[,[recordnumber&][,variable]]
PUT [#]filenumber%[,[recordnumber&][,variable]]

Description / Parameter(s)

filenumber% The number of an open file.
recordnumber& For random-access files, the number of the record to read or write. For binary-mode files, the byte position where reading or writing starts.
variable For GET, a variable used to receive input from the file. For PUT, a variable that contains output to write to the file. The variable is usually a variable of a user-defined data type.

Example

TYPE TestRecord Student AS STRING * 20 Score AS SINGLE END TYPE DIM MyClass AS TestRecord OPEN "FINAL.DAT" FOR RANDOM AS #1 LEN = LEN(MyClass) MyClass.Student = "MarySa" MyClass.Score = 99 PUT #1, 1, MyClass CLOSE #1 OPEN "FINAL.DAT" FOR RANDOM AS #1 LEN = LEN(MyClass) GET #1, 1, MyClass PRINT "STUDENT:", MyClass.Student PRINT "SCORE:", MyClass.Score CLOSE #1 KILL "FINAL.DAT"