[Prev] [Next] [Contents] [Commodore] [New] [Search] [Home]

System Specification for C65Fred BowenMarch 1, 1991

The INPUT statement can only be executed from within a program.

LINE INPUT allows the program to input a string which includes any PETSCII character (including colons, commas, imbedded spaces, etc.) up to but not including a null or return character. There should be only one string-type variable name in the variable list in this case, but if there are more the computer prompts as usual with two question marks for more data to assign to the additional variables.

    10 INPUT "WHAT'S YOUR FIRST NAME AND AGE"; NA$,A
    20 PRINT "YOUR NAME IS ";NA$;' AND YOU ARE';A," YEARS OLD"
The above INPUT is the traditional BASIC form.
    10 LINE INPUT "WHAT'S YOUR ADDRESS"; ADS
    20 PRINT "YOUR ADDRESS IS: ";AD$
The above INPUT allows an entire line of data to be assigned to a string variable, including commas and other common punctuation marks.
    10 INPUT "ENTER YOUR NAME HERE: ", NA$
The above INPUT suppresses the traditional '?' prompt by using a comma instead of a semicolon after the prompt string. To suppress the '?' without a prompt string, make the prompt string null.

INPUT# - Input data from an 1/0 channel (file)

    [LINE] INPUT#logical_channel-number, variable-list

The INPUT# command works like the INPUT command, except no prompt string is allowed and input is gathered from a previously OPENed channel or file. This command can only be used in a program.

The logical - channel number is the number assigned to the device (file) in an OPEN (or DOPEN) statement. Items in the variable list must agree with the type of data input, or a 'FILE DATA ERROR' will result.

On the C64DX, an End Of File (EOF) condition or bad I/O status will terminate input, as if a return character was received. It's good practice to examine the I/O status byte (and the DS disk status for file I/O) after every I/O instruction to check for problems or errors.

    10 DOPEN#1,"FILE"                                   This program will
    20 C=0                                              count the number of
    30 DO: LINEINPUT#1,A$: C=C+l: LOOP UNTIL ST         lines in FILE
    40 DCLOSE#1
    50 PRINT"FILE CONTAINS";C;" LINES."



[Prev] [Next] [Contents] [Commodore] [New] [Search] [Home]
This page has been created by Sami Rautiainen.
Read the small print. Last updated August 11, 2003.