- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm working with a program which use Excel spreadsheet to take input data and write to an input file, then use a Fortran Console application to read that input file, perform some calculation and then write to several output files. The question is the location of the input file created by Excel may very. how could the Fortran Consonle application know where to find it. Is there anyway I could pass an argument or commnd line from Excel to Fortran exe.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sure, see NARGS/GETARG:
and change all your open statements so that they look like:
HTH
Jugoslav
PROGRAM Foo USE DFLIB CHARACTER (MAX_PATH):: sDir="" IF (NARGS() .GT. 0) CALL GETARG(1, sDir)
and change all your open statements so that they look like:
OPEN (11, FILE=TRIM(sDir)//"input.txt")
HTH
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can also consider writing an Excel VBA macro to pass an argument directly to a Fortran DLL. You can probably change your console application to a DLL by changing its main program to a subroutine. If you do, though, the Fortran code shouldn't write any output to the console. The console won't exist unless the DLL explicitly creates it. Writing to and reading from files is OK.
Mike
Mike
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