qb45advr.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
INPUT # Statement Programming Example
  QuickSCREEN      Details     Example      Contents      Index
──────────────────────────────────────────────────────────────────────────────
INPUT # Statement Programming Example
 
This example reads a series of test scores from a sequential file
and calculates the average score.
 
' NOTE: Before you run this program, create a one-line data file
'       CLASS.DAT made up of a series of test scores -- 97 84 63 89 100.
 
DEFINT A-Z
CLS    ' Clear screen
OPEN "class.dat" FOR INPUT AS #1
 
DO WHILE NOT EOF(1)
   Count = Count + 1
   INPUT #1, Score
   Total = Total + Score
   PRINT Count; Score
LOOP
PRINT
PRINT "Total students:";Count;" Average score:";Total / Count
END
 
Sample Output
 
1  97
2  84
3  63
4  89
5  100
 
Total students: 5  Average score: 86.6