in BASIC ROM:
|List of all BASIC keywords|
Type: Command General Programming-Syntax: INPUT# <logic file number>,<variable>[,<variable>...]
The BASIC command INPUT# is used for reading data from a file stored on peripheral device media such as disk or tape. INPUT# reads complete data consisting of maximum 80 characters into variables and not only single characters as the GET# command.
Before INPUT# can be used, a channel to the destination device has to be established with the OPEN command. The INPUT# command must address the same logical file number as the preceding OPEN command. The dataset for a variable (string or numeric) always ends, when a comma <,>, a semicolon <;>, a colon <:> or a character <CHR$(13)> occurs. These symbols can only be read within double quotes <"">. INPUT# can also read the screen memory, regarding any logical screen line (40 or 80 characters) until one of the aforesaid interrupting characters occurs. After each line the cursor automatically moves one line further.
If data are read into a numeric variable but do not have numeric content, the BASIC interpreter will report "?BAD DATA". Using string type variables only, can prevent this error report from occurring. If the 80 characters maximum for a variable is exceeded, the BASIC interpreter reports "?STRING TOO LONG". You can only use the INPUT# command within programs. If you type it in otuside of a program, there will be an "?ILLEGAL DIRECT ERROR".
10 DIM A$(25) 20 PRINTCHR$(19);: OPEN 1,3 30 FOR X=1 TO 25: INPUT#1,A$(X): NEXT X 40 CLOSE 1 50 PRINTCHR$(147); 60 FOR X=1 TO 24: PRINT A$(X): NEXT X 70 PRINT A$(25) CHR$(19)
This program reads the whole 25 screen lines into the indicated string variables A$(X) (<-- program lines 20-40) and then reprodruces them again on the screen.
10 OPEN, 1, 1, 0, "TESTFILE" 20 INPUT#1,A$(1) 30 INPUT#1,B$, C$, D$ 40 CLOSE 1
Reading a dataset from tape (for writing check PRINT#).
10 OPEN 2, 8, 4, "TESTFILE, SEQ, R" 20 INPUT#2,A$(1) 30 INPUT#2,B$, C$, D$ 40 CLOSE 2
Reading a dataset from the first disk drive (for writing check PRINT#).
10 OPEN 1,0 20 INPUT#1,A$ 30 PRINT A$ 40 CLOSE 1
Using the monitor as device. The advantage is: no INPUT prompt or no error message ?EXTRA IGNORED.