9

The CALL/360:BASIC manual has a couple of simple examples of file I/O. This one has me scratching my head:

10 OPEN 10, 'ITEMFILE', INPUT 
20 GET 10: A$,A,B,C,D
30 LET Al = (A+B+C+D)/4
40 PRINT USING 50, A$,Al
50 :AVERAGE PRICE FOR A ######## IS $#.## 
60 GOTO 20
70 CLOSE 10
80 END

It explains:

Line 60 returns control to line 20 where a new item is read and the average price is computed. The loop is maintained until the file is exhausted and the END OF FILE message is printed.

So... it just errors out and never closes the file? So why is there a line 70?

Is there unexplained magic here that causes it to continue after 60, or is this as bad as it seems?

1
  • My question would be “how does it know to go to line 70, since there’s no ON ERROR clause.
    – RonJohn
    Commented Jun 6, 2022 at 4:58

1 Answer 1

8

So... it just errors out and never closes the file? So why is there a line 70?

Left over from the previous program?

Is there unexplained magic here that causes it to continue after 60, or is this as bad as it seems?

Nope, it's exactly as it seems. The program terminates as there is no EOF handler defined. The message shown is really a BASIC error message telling that EOF happened at line 20, see p.86.


I remember that any kind of error handling (EXLST) would have needed to be done by system commands. This, BTW, includes the creation of files. Any file a BASIC (or any other program) wants to write has to be first established on a device by a file command, defining the location and initial size of that file - so the first example will only work by executing a command prior to running the program - much like shown.


It might be helpful to understand that CALL/OS was an attempt of IBM to break their /360 into the upcoming world of "personal computing" - like it just came to be with the first affordable mini computers. BASIC was in that context meant as an easy scratch language to run across some data for ad hoc evaluation. More like a scripting language directed at non-programmers, not a fully-featured environment (*1). 'Serious' applications for CALL/OS were to be written in PL/1, or the later added FORTRAN. Note that COBOL was absent (at least as I remember) as that was meant for 'real' applications, not something that would be touched by users of CALL/OS :))


In the age of card-based data, it was common to have a dedicated end-of-file card. Besides simplifying some programs, it was mostly due to the fact that card databases could be larger than a single card reader hopper, so sensing 'No Card' wasn't really EOF, but a hint to add the next stack. Depending on OS and setup this was signalled to the operator without even telling the user program.

With that in mind, it seems understandable that a missing EOF handling wasn't so much of a concern to mainframe people. Kinda different for Mini/ Personal Computers.


*1 - Not to mention that BASIC itself was, in 1970, still in its infant days as a learner's language. In fact, Dartmouth BASIC only added the ability to read and write files with its Fifth Edition in late 1970, after CALL/360 BASIC was introduced. So all file related commands are additions done b IBM. Funny side note: Dartmouth BASIC used the END keyword to check for EOF as in IF END THEN CLOSE.

1
  • 1
    "Left over from the previous program?" - good guess, very Rugg/Feldman. But nope, previous program stopped at 60. Someone at IBM sat down and wrote a borked program for a manual... Commented Jun 4, 2022 at 12:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .