next up previous index
Next: Environment Variables Up: Environment Access Previous: Environment Access

Command Line Arguments

Arguments provided on the UNIX command line are accessed by the builtins       argc/1 which gives the number of command line arguments (including the command name itself) and argv/2 which returns a requested positional argument in string form. The following example makes a list of all command line arguments:

 collect_args(List) :-
        argc(N),
        collect_args(N, [], List).
 collect_args(0, List, List) :- !.
 collect_args(N, List0, List) :-
        N1 is N-1,
        argv(N1, Arg),
        collect_args(N1, [Arg|List0], List).


Micha Meier
Mon Mar 4 12:11:45 MET 1996