Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Failure to open a file that exists

Status
Not open for further replies.

WillBryce

Technical User
Sep 8, 2024
4
Using Plato & F90 with the program on a memory stick, I want to write a file, remove and then re-connect the stick and then read the file. The following program fails at line 26 with the message 'A device which does not exist ...'. What's wrong?

PROGRAM SSFM5 ! stored on memory stick
IMPLICIT NONE

CHARACTER*8 MESSAGE
LOGICAL EX
INTEGER ISCR

ISCR=6

OPEN (7,FILE='Xtime.txt',STATUS='new') ! write to stick
WRITE (7,*)'ABC'
CLOSE(7)
CALL SLEEP@(5)
WRITE(ISCR,*)' DISCONNECT NOW'

1 INQUIRE(FILE='Xtime.txt',EXIST=EX) ! test for disconnect
IF (EX) GOTO 1
WRITE(ISCR,*)
WRITE(ISCR,*)' OK'
WRITE(ISCR,*)' WAIT FOR A FEW SECONDS THEN RECONNECT'

2 INQUIRE(FILE='Xtime.txt',EXIST=EX) ! test for connect
IF (.NOT. EX) GOTO 2

OPEN (7,FILE='Xtime.txt') ! read from stick
READ(7,'(A)')MESSAGE
CLOSE(7)
WRITE(ISCR,*)MESSAGE

3 GOTO 3
END
 
Your program SSFM5 and the text file Xtime.txt that it writes and reads are on the memory stick and you try to remove the memory stick while the program is running?
 
Yes. Not uncommon? Save a file to a stick in, say, Word. Take the stick out, replace it and reload the file. Works OK.

This is not quite the same though since in the .exe program SSFM5 is stored on the stick.
 
Last edited:
Yes in that case Word running EXE is on the PC hard disk and the file is on the stick

But in your case, it's different: your running EXE and the file are both on the stick
 
But hasn't the .exe been loaded into the program memory and is running just like a program loaded from the HDD? Why should it need to consult its source?
 
But hasn't the .exe been loaded into the program memory and is running just like a program loaded from the HDD? Why should it need to consult its source?
see this:
 
Try to run your program from the hard disk and place only your text file on the stick to see if it works or not.
 
I will do that tomorrow but I have no doubt that it'll work - as per Word.

Correction:
Just done it - changing the file name to the stick adding 'D:/Xtime ...
Worked OK - as expected.

But I now find that this version (adding the path 'D:/') to the program in 'D', it works OK.
The 'D' program seems to have lost the folder that it's in.
 
Last edited:
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top