* *
*
* * News
 • Daily news
 • Archived news

Columns
 • WildCard
 • Qbasic Articles
 • QB Comic!

Learning center
 • QB Books
 • Qbasic Lessons!
 • Qbasic FAQ
 • Newbies Section
 • Qbasic Tutorials

* *
*
*
*
*  
.EOF Function Programming Example.

  QuickSCREEN      Details     Example      Contents      Index
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
EOF Function Programming Example
 
This example reads single-precision values from the file DATA.IN into an
array M using a DO LOOP. The loop uses the EOF function to signal the
end of the file. A second DO LOOP displays the contents of M to confirm
that it contains the values from DATA.IN.
 
This example will not run without a DATA.IN data input file.
 
DIM M(0 TO 2000)
 
OPEN "DATA.IN" FOR INPUT AS 1
C = 0
DO WHILE NOT EOF(1) AND C <= 2000
      INPUT #1, M(C)
      C = C + 1
LOOP
 
CLS    ' Clear screen
D = 0
DO WHILE D < C
      PRINT M(D)
      D = D + 1
LOOP
 
  Tip: Run the example with a simple DATA.IN data file you create
       with a text editor. For example, create a one-line DATA.IN file with
       the following sequence of numbers:
 
       10 20 30 40 50 60 70 80 90
 
       Then run the example program to produce the following sample output.
 
Sample Output
 
10
20
30
40
50
60
70
80
90
 
* * ** * * * *