- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to open an ascii file which is currently opened in Excel.
Unsurpringly the program crashes. [severe (30); open failure on Unit]
Is there a compiler directive to allow the file to be opened in a read-only mode ?
I have tried the various ACTION='READ' & SHARED options in the open command.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ACTION='READ' would be your best hope in the Fortran code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yes notepad and word and indeed MS-DOS editor can all open the file when Excel has it opened (MS word evebn produces a fancy dialogue panel, telling me its locked and sking if I want it as Read only)
Ther must be someway of doing this in Fortran ..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How about executing a shell COPY command to copy the file to a temp file. Then open the temp file. You wouldn't get an error status but you could delete the potential temp file first, then COPY, then if temp file exists assume copy succeeded.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The Fortran run-time automatically tries opening the file for read-only access if it fails to open for write. You could specify ACTION='READ',SHARE='DENYNONE' to be most permissive, but my tests so far show this is not required.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
the code is simple:
program count_recs
c
c read in a file and see how many records it has
c
character*256 fname
character*80 line
c
fname='W:DieselEnginedsl_bw_and_w_new_w_matrices'//
& 'jmoffat_b_w_Jun 2007.csv'
c
open(12,file=fname,status='old',Action='read')
c
10 read(12,'(a)')line
write(6,*)'opened and read ',line(1:20)
close(12)
c
stop
end
I've attached a screen dump of the error.
It may be worth pointing out I',m actually using CVF v 6.1 at this point ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Actually, this seems to cure the issue for me ..
open(12,file=fname,status='old',Action='read',
& share='denynone')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page