Input loop is part of Short Circuit's Console Program Basics selection.
Task

Read from a text stream either word-by-word or line-by-line until the stream runs out of data.

The stream will have an unknown amount of data on it.




CHARACTER name='myfile.txt', string*1000
 
   OPEN(FIle=name, OLD, LENgth=bytes, IOStat=errorcode, ERror=9)
 
   DO line = 1, bytes  ! loop terminates with end-of-file error at the latest
      READ(FIle=name, IOStat=errorcode, ERror=9) string
      WRITE(StatusBar) string
   ENDDO
 
 9 WRITE(Messagebox, Name) line, errorcode