' This program reads n name-age pairs from ' a text file on disk CLS ' Open the file with name "list.txt" to be read from, ' as file #1 OPEN "list.txt" FOR INPUT AS #1 DIM n AS INTEGER DIM i AS INTEGER ' Read n, the first number in the file ' This tells us how many name-age pairs will follow INPUT #1, n ' Show the value read from the file PRINT "n="; n ' Declare the arrays that will hold the data DIM nm(n) AS STRING DIM age(n) AS INTEGER ' Read the name-age pairs from the file #1 ' The file contains one line per data item FOR i = 1 TO n INPUT #1, nm(i) INPUT #1, age(i) NEXT ' Print the data read FOR i = 1 TO n PRINT nm(i); age(i) NEXT ' Now close the file before the program ends CLOSE #1