Software Archive
Read-only legacy content
17060 Discussions

Open statement failure

Intel_C_Intel
Employee
332 Views
The following open statement is not working in Visual Fort ran 6.0
and Windows 2000.

open (unit=35,file=cc:cashflow.cfi',
* status=old',action=read',iostat=is)

I physically check the file. It does exist and I have full access of it. The same statement in Fort ran 4.0 and Win 95
works OK (even though it sounds working in some machines but not others).
Anybody has idea what is the problem and how to fix
it.

Thanks.

Roger Lei
0 Kudos
2 Replies
Steven_L_Intel1
Employee
332 Views
What is the value of the IOSTAT variable after the OPEN fails? What error is displayed if you leave off IOSTAT=?

Steve
0 Kudos
Intel_C_Intel
Employee
332 Views
It is not necessarily helpful on this particular one, but because there are a lot of problems with opening files, here is a useful little utility for checking on the existence of a file. I inherited it many years ago and it is by now a well-used member of my user utilities library. Its name is easier for bears to remember than the single line of code that it contains, is an alternative to putting STATUS = ?OLD? in the OPEN statement and is in a form that keeps the code flowing, eg:

IF (FIND_FILE(INPUT_DATA_FILE)) THEN
OPEN(UNIT=1, FILE=INPUT_DATA_FILE, ACTION=?READ?)
ELSE
WRITE(*,*) ?INPUT DATA FILE NOT FOUND?
PAUSE
STOP
END IF

 
      LOGICAL*1 FUNCTION FIND_FILE(FILE1) 
C 
C     THIS FUNCTION RETURNS TRUE IF "FILE1" EXISTS, OTHERWISE FALSE. 
C     ARG:  CHARACTER*(*)  FILE1 - NAME OF FILE 
C 
      IMPLICIT NONE 
      CHARACTER* (*) FILE1 
C 
      INQUIRE (FILE=FILE1, EXIST=FIND_FILE) 
    END 


Bear of little brain
0 Kudos
Reply