- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
After building an executable I get error code 29 when trying to open a file. The program should open a windows explorer and allow the user to select a file in the same directory as the executable. The program works as expected in visual studio 2019 in release or debug mode but throws the error 29 after building the executable. The code was inherited and I'm trying to run the existing code as is with an executable.
The portion of code that is causing the issue is as follows:
1001 Open(11,FILE=' ',READONLY,STATUS='OLD',ERR=1004,IOSTAT=Iodum)
If(Iodum.eq.0) goto 1005
1004 Type *, 'Error opening Calibration, Err = ',Iodum
Type *, 'Do you want to try again? (Y/N)'
write(16,*)'Error opening Calibration, Err = ',Iodum
write(16,*)'Do you want to try again? (Y/N)'
read (5,*)query
if ((query.eq.'y').or.(query.eq.'Y')) goto 1001
fail=.true.
return
I have limited fortran knowledge. Thanks for any help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, this worked out perfectly.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That must be a non-standard of some vendor's Fortran (OPEN with blank file name calling OpenFileDialog).
It would be best if you made a C interoperable C++ function to use OpenFileDialog to return the fully qualified file specification.
Untested code:
OpenFileDialog ofd = new OpenFileDialog(); ofd.InitialDirectory = @"c:\"; ofd.Title = "Browse for file to open"; ofd.Filter = "All files (*.*)|*.*|txt files (*.txt)|*.txt|doc files (*.doc)|*.doc|docx files (*.docx)|*.docx|mp3 files (*.mp3)|*.mp3|pdf files (*.pdf)|*.pdf|html files (*.html)|*.html"; ofd.FilterIndex = 2; ofd.RestoreDirectory = true; if (ofd.ShowDialog() == DialogResult.OK) { // *** here you return ofd.FileName to the Fortran file name variable
return; } // error return
Then use that file name in your Fortran OPEN statement
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is an old Microsoft extension. Compile with /fpscomp:filesfromcmd to enable it. fpscomp (intel.com)
- 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