Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28923 Discussions

Getting error code 29 on open with executable

pr_777
Novice
870 Views

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. 

0 Kudos
1 Solution
pr_777
Novice
829 Views
0 Kudos
3 Replies
jimdempseyatthecove
Honored Contributor III
860 Views

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 

0 Kudos
Steve_Lionel
Honored Contributor III
850 Views

This is an old Microsoft extension. Compile with /fpscomp:filesfromcmd to enable it. fpscomp (intel.com)

0 Kudos
pr_777
Novice
830 Views

Thanks, this worked out perfectly.

0 Kudos
Reply