- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If a program requires one or more command line arguments, how do you do start to debug it within the Visual Studio environment?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Debugging > Command Arguments project property.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve,
I've tried this but my command arguments are being ignored. I am using VS 2015 and Fortran 16. My application calls the NT function GetCommandLine(). The return value is the executable file name only.
Previously this was working with VS 2010 and Fortran 12. The return value from GetCommandLine() is the executable file name and command arguments.
Brian.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I use
CALL GET_COMMAND_ARGUMENT(1,DATAFILENAME,LENFILE,STATUS)
Where the '1' refers to the first argument after the command itself (the latter being obtained using '0').
The argument goes into character string 'DATAFILENAME' and its length into integer LENFILE.
Any STATUS>0 is a failure.
Confusingly, if you need to run the release version with a command line argument, you have to do what Steve says under project properties again, but this time for the 'release' version. It's confusing that you have to select the 'debugging' option under the 'release' version, since you expect and get no debugging with it when you run it from Visual studio by selecting 'Start without debugging'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As with all the property pages, the default is to apply changes to the current configuration only. If you want it to apply to all configurations (and/or all platforms), you have to say so using the dropdowns at the top of the property page.
My guess is that Anthony is on the right track in suggesting you need to add the arguments for the current configuration.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
this works very well:
! command-line arguments
nargs = IARGC()
IF (nargs > 0) THEN
DO j = 1, nargs
CALL GetArg (j, argbuf, status)
IF (status <= 0) EXIT
IF (INDEX(argbuf, '-whatever') > 0) !set your flag
! and so forth
END DO
END IF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would very strongly recommend using the Fortran standard intrinsics GET_COMMAND, GET_COMMAND_ARGUMENT and COMMAND_ARGUMENT_COUNT. There is no need to use nonstandard library routines that may have different behaviors on different platforms.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
A couple of short points...
1. The debug properties are set correctly. It's not pilot error (as far as I can tell, but I've been wrong before).
2. There appears to be many ways to get command line arguments, as suggested by Steve, Anthony and Paul. Diversity is good.
3. One of the ways to get command line arguments that used to work no longer does so when run against a Fortran console application from within VS 2015 (no issues though when run from a Windows shell). Unexpected loss of functionality is bad.
4. Command line processing is handled by a utility library in a common way for all our products (C, C++ and Fortran), which is why we use the NT GetCommandLine() function. I don't live in a Fortran-only universe.
Brian.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I suggest to run a quick test on GET_COMMAND_ARGUMENT to ensure it is not GetCommandLine(). that is broken...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Brian Francis wrote:
A couple of short points...
1. The debug properties are set correctly. It's not pilot error (as far as I can tell, but I've been wrong before).
...
3. One of the ways to get command line arguments that used to work no longer does so when run against a Fortran console application from within VS 2015 (no issues though when run from a Windows shell). Unexpected loss of functionality is bad.
Things work for me here. Check your #1 again, making sure that the configuration that you are modifying is the configuration that you are running (the mapping between solution and project configuration is set via Build > Configuration Manager).

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