Table of Contents

INPUT#

Syntax

INPUT #<logical file number>, <variable> [, <variable>] ...

The INPUT# command is used for reading strings from a file, into one or more variables. The file must be opened beforehands using the OPEN command.

Differences from CBM BASIC:

  • All variables must be of type STRING.
  • Only the comma (,) character is recognized as record separator. If the input is between quotes (") the comma is regarded as part of the string.

Example

This example demonstrates writing to and reading from a sequential file:

OPEN 2, 8, 4, "testfile,s,w"
PRINT #2, "{34}quoted,string{34}", "one";"more", "record"
CLOSE 2

PRINT "file written. now reading..."

DIM a$ AS STRING * 12
DIM b$ AS STRING * 12
DIM c$ AS STRING * 12

OPEN 2, 8, 4, "testfile,s,r"
INPUT #2, a$, b$, c$
PRINT a$, b$, c$
CLOSE 2

See also