Hi Pete,

Sometimes when you get stuck, look at the refinements of the function you
are using.

? do
Evaluates a block, file, URL, function, word, or any other value.
Arguments:
    value -- Normally a file name, URL, or block
Refinements:
    /args -- If value is a script, this will set its system/script/args
        arg -- Args passed to a script. Normally a string.
    /next -- Do next expression only.  Return block with result and new
position.


do/arg is what you are after...


; Changed to show all args are passed
REBOL [Title: "Param Test" file: %param.r]
either string? system/script/args [
    args: parse system/script/args none
    foreach arg args [print arg]
][
    print "No arguments passed."
]

do/args %param.r reform ["List" "of" (2 + 2)  "args" ]
Script: "Untitled" (none)
List
of
4
args

The above works. IMHO Depending on what I need to achieve, I would hardly
ever use the do/args aproach, more commonly I would do a script and then
call the functions in it, this allows me to use
scripts as libraries of functions.

Cheers,

Allen K.



----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 16, 2000 3:48 AM
Subject: [REBOL] pleh! pleh! basic reborientation needed!


> I started out with much energy, and am now floundering on the simplest
things.
>
> I cannot get *anything* to do with command line arguments to work at all.
> I have tried c&p-ing examples from messages here, and they don't work.
>
> (Well... K.R.'s path example seemed to work for what it was worth,
> and I now surround the inner part of each script with:
> -------------------------------------------------------------
> savecd: system/script/parent/path
> ...
> change-dir savecd
> -------------------------------------------------------------
> so I don't have to change-dir back after every do %...)
>
> Anyway, something as simple as...
>
> >> do %projects/test/params.r "doggy"
> (alternately: do %projects/test/params.r doggy
>           or: do %projects/test/params.r [doggy]
>           or: do %projects/test/params.r ["doggy"])
>
> params.r (just the guts, ma'am)
> -------------------------------------------------------------
> ; yeeth! just gimme the first one!
> either string? system/script/args [
>     args: parse system/script/args none
> print args/1
>
> ][
> print "No arguments passed."
> ]
> -------------------------------------------------------------
> or should that be:
> -------------------------------------------------------------
> ; by this time, I really don't care if there were no params!
> args: parse system/script/args none
> forall args [
> print args/1
> ]
> -------------------------------------------------------------
> finally:
> -------------------------------------------------------------
> >>do %something "please!"
> -------------------------------------------------------------
>
> I've tried every combination I can think of for the last hour without
success.
> Like using system/options/args... different looping constructs, different
number
> of parameters on the command line, etc. If anyone wants to observe me
losing it
> in detail, I can send a copy (13K) of my last session history on request.
>
> Going (?) nuts.
>
> --
> Pete Wason|"LWATPLOTG"|[EMAIL PROTECTED]|[EMAIL PROTECTED]|CUCUG|TA|PHX
>
> PS: This whole thing strikes me as kind of funny, since the first thing I
did in
> rebol was a directly interpreted one-liner that checked a webserver for
its
> status and sent an email if it was down -- which worked on the first try.
Maybe
> it was something I ate for breakfast...
>
>

Reply via email to