No. The program reads the first three lines of the file, only. Hopefully, each line contains one integer.
Here is another program, similar to the previous program, but it does some computation with the values it reads.
INPUT "Enter file name:", NAME$ ' Ask user for a file name OPEN NAME$ FOR INPUT AS #1 ' INPUT #1, NUM LET SUM = NUM ' INPUT #1, NUM LET SUM = SUM + NUM ' INPUT #1, NUM LET SUM = SUM + NUM ' PRINT "The Sum is:", SUM END
The program
first asks the user for the file name,
then opens that file for INPUT.
The file should be located in the same directory as the default directory
of the program.
The program reads the number on the first line into NUM
.
SUM
is then initialized to that value.
Next, the program then reads in the next number in the file into NUM
and adds NUM
to SUM
.
Then it reads in the third number and adds that to SUM
.
Finally it prints out the sum of the three numbers.
Can more than one program use the same data file?