Yes.
Say that the following data were contained in a file. The first line of the file says how many patients it holds data for. The data for a patient consists of a name (on one line) followed by a cholesterol level (on the next line). For example, here is the data for 5 patients:
5 Bruce Anderson 230 Marla Cook 180 Dean Estes 250 Marcia Gould 215 Glenn Olsen 195
Here is a program that reads in this data patient by patient and writes out the name and cholesterol level of the patient who has the highest level.
INPUT "File Name: ", NAME$ OPEN NAME$ FOR INPUT AS #1 INPUT #1, NUMP ' Read the number of patients LET MAX = 0 ' Start the highest reading at 0 LET COUNT = 1 DO WHILE COUNT <= NUMP INPUT #1, PATIENT$ ' Read patient name INPUT #1, LEVEL ' Read their chol. level IF LEVEL > MAX THEN ' If this patient has the MAX = LEVEL ' highest level so far, MAXNAME$ = PATIENT$ ' remember their level and name END IF LET COUNT = COUNT + 1 LOOP PRINT MAXNAME$, "has the highest level, which is ", MAX END
The program starts out by asking for the file name and then opeing that file for input. Then it reads in the number of patients.
The DO
loop reads a set of data for each patient.
It reads the patient's name (one one line) and their cholesterol level (on the following line).
It then compairs that level with the highest level seen so far.
If the current level is higher, it becomes the highest level seen
and the name of the corresponding patient is also remembered.
At the end, the program writes out the name and level of the patient with the highest level.
Have you read about all you want to read about reading files?