- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In debug environment only two args are returned from the command line
t.exe "3""4" "5" 6 "7"
They are
t.exe
3"4 5 6 7
now I would expect 5 arguments to be returned, namely
t.ext
3"4
5
6
7
Is this an error in GETARG?
Fortran is
program t
parameter (ia=15)
character args(-2:ia)*20
integer*2 i,j
print *,'iargc,nargc',iargc(),nargs()
do 100 i=-2,ia
call getarg(i,args(i),j)
print *,i,args(i),j,len(args(i))
100 continue
end
with screen o/p
iargc,nargc 1 2
-2 -1 20
-1 -1 20
0 H:SgastlibCOMCHART 40 20
1 3"4 5 6 7 9 20
2 -1 20
3 -1 20
4 -1 20
5 -1 20
6 -1 20
7 -1 20
8 -1 20
9 -1 20
10 -1 20
11 -1 20
12 -1 20
13 -1 20
14 -1 20
15 -1 20
Press any key to continue
t.exe "3""4" "5" 6 "7"
They are
t.exe
3"4 5 6 7
now I would expect 5 arguments to be returned, namely
t.ext
3"4
5
6
7
Is this an error in GETARG?
Fortran is
program t
parameter (ia=15)
character args(-2:ia)*20
integer*2 i,j
print *,'iargc,nargc',iargc(),nargs()
do 100 i=-2,ia
call getarg(i,args(i),j)
print *,i,args(i),j,len(args(i))
100 continue
end
with screen o/p
iargc,nargc 1 2
-2 -1 20
-1 -1 20
0 H:SgastlibCOMCHART 40 20
1 3"4 5 6 7 9 20
2 -1 20
3 -1 20
4 -1 20
5 -1 20
6 -1 20
7 -1 20
8 -1 20
9 -1 20
10 -1 20
11 -1 20
12 -1 20
13 -1 20
14 -1 20
15 -1 20
Press any key to continue
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No bug in GETARG. Use 0 as the first argument to return the name of the executable file on the command line. The confusing thing is that the function NARGS() returns the number of command line arguments including the executable file.
![](/skins/images/895D6060305DF45A57FACF854B5A8CD1/responsive_peak/images/icon_anonymous_message.png)
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