Silverfrost Forums

Welcome to our forums

READ* causes run-time error after file has been opened/close

14 Aug 2017 3:08 #20008

Hello, everyone,

I opened a file using

OPEN(UNIT=1,FILE='...',STATUS='old',IOSTAT=stats)

after reading data from that file, I closed it again, using

CLOSE(UNIT=1)

After that, READ* - which should get user input from the command promt returns

'Run-time error 94: Unit has neither been OPENed nor preconnected'

PRINT*,'...' on the other hand, works just fine.

How can I open the command prompt for input again?[/quote]

14 Aug 2017 3:31 #20009

I think that it is advisable not to use low-numbered units in an OPEN statement, as the idea is that they are 'pre-connected'. Old-fashioned advice was to avoid units 5 and 6, because traditionally they were the card reader (5) and line-printer (6). On the first machine I ever used, 1 was the operator's console, 2 and 3 were tape readers, and 4 was the tape punch. 7 was another card reader!

If you are using a pre-connected unit, never CLOSE it, or you are likely to get the problems you describe. A unit number given as * is also pre-connected. If a UNIT is pre-connected, you do not need to OPEN it.

The advice given in FTN95.CHM is: 'UNIT values should be greater than 6 to avoid the possibility of re-assigning standard input/output streams.'

Eddie

14 Aug 2017 4:17 #20010

Thanks for the detailed explanation!

I'm working with code that someone had written back in the 90's. They only excluded 5 and 6.

Please login to reply.