- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need help with opening files with the class I'm teaching. When I use the open command, Fortran can't open the file because the file was saved to a different directory than what the program was on. Because of administrative difficulties at school, I am unable to save files on the directory where Fortran is located. Are there any directory commands I could use, so that Fortan can find the file and open it?
Thanks in advance for any assistance.
Thanks in advance for any assistance.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No sure if I understand correctly, but you may try the following:
Open(Unit=8, Path, Status = 'Old'.....)
For example if Fortran directory was on C drive and MyFile.dat was saved to MyDir on E drive, then Path = 'E:MyDirMyFile.dat'
or
Open(Unit = 8, File = 'EMyDirMyFile.dat', Status = 'Old'.....)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I assume you are using a Visual Fortran?
If you need to find files, then you need to use the GETOPENFILENAME function (see under FORTRAN help). Here is a Compaq Visual Fortran workspace (findfileandopenit.dsw) that contains two projects: one called FINDFILEANDOPENIT.DSP and one called FINDIT.DSP.
The first (FINDFILEANDOPENIT) is based on a simple 'Hello world' console program. When compiled and executed, it will display a console window and then (after printing 'hello world'), It will execute some GETOPENFILENAME code to open an Explorer-type commondialog that allows you to select a file name (use the drop-down filter list box to select thewild-card '*.*' file-type to be sure of getting some files toselect as a test). Having selected a file, the program ends by displaying a messagebox that shows the selected filename broken down into its component parts (drive, path, name , file extension etc.)
The second (FINDIT) is a simple windows program with a menu bar. One of the menu options, the 'File' menu, has an option 'New' under it, which, when selected, sends the message IDM_NEW to the window procedure, which willl open the same Explorer-type commondialog as before. You will find the same GETOPENFILENAME code inside the main window procedure called MainWinProc, and following the CASE(IDM_NEW) statement. HTH.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page