[REBOL] Re: Argument passing
From: jeff:rebol at: 5-Apr-2001 22:49
Andrew Martin passed along someone's question:
> > The question is - How does one pass a dynamic list of
> > arguments to a REBOL script invoked from: a) the rebol
> > command line b) a DOS batch file c) a Unix shell script?
With Core 2.5 you can take any number of args from the
command line which are split into separate arguments found
in system/options/args:
Try this script (unix version):
;-------------------------------
#!/path/to/rebol
REBOL [
Title: "Args checker"
]
foreach obj [options script][
print [obj #== mold get in system/:obj 'args]
] quit
;-------------------------------
Call the script rargs, put it in your path, make it executable
and then try stuff like:
rargs 1 2 3
rargs "1 2" 3
etc..
You should see that system/options/args winds up being set to
a block containing each argument as a separate string. Then
if you want to have fun you can use PARSE on the block and set
various options in a pretty simple way:
rest: copy []
parse system/options/args [
some [
"-q" (quiet: true) |
"-v" (verbose: yes) |
"-x" (experimental: on) |
set other string! (append rest other)
]
]