getarg and iargc access arguments on the command line (after expansion by the command-line preprocessor.
The subroutine is called by:
|
call getarg( k, arg ) |
|||
|
k |
INTEGER*4 |
Input |
Index of argument (0=first=command name) |
|
arg |
character*n |
Output |
kth argument |
|
n |
INTEGER*4 |
Size of arg |
Large enough to hold longest argument |
The function is called by:
|
Return value |
INTEGER*4 |
Output |
Number of arguments on the command line |
Example: iargc and getarg, get argument count and each argument:
demo% cat yarg.f
character argv*10
INTEGER*4 i, iargc, n
n = iargc()
do 1 i = 1, n
call getarg( i, argv )
1 write( *, ’( i2, 1x, a )’ ) i, argv
end
demo% f95 yarg.f
demo% a.out *.f
1 first.f
2 yarg.f
|
See also execve(2) and getenv(3F).