Hi Eric,

you could use this ...

Those were the words of [EMAIL PROTECTED]:
> Hi ! 
> 
> Newbie question !!!
> 
> Is it possible to test a lack of argument in a function ? 
> I try things like this but... it doesn't work !

unset!: do [type?]        ; this defines unset!

tst: func [
    {help for tst...}
   x [integer! unset!]    ; allow unset! values
][ 
   if not value? 'x [     ; test if x has got a value, use '
                          ; to get x litarally you'd get en error 
                          ; with unset values otherwise
        help tst 
        exit              ; exit the function
   ]
   print x
]

if you want to use tst without args in a script, you have to
use it at the end of a paren! e.g. (tst) because tst will eat
up everything that follows

>> tst
help for tst...
Arguments:
    x --  (integer unset)
>> tst 3
3
>> (tst)
help for tst...
Arguments:
    x --  (integer unset)
>> tst "a"
** Script Error: tst expected x argument of type: integer unset.
** Where: tst "a"


regards,

Ingo

--  _     .                                _
ingo@)|_ /|  _| _  <We ARE all ONE   www._|_o _   _ ._ _  
www./_|_) |o(_|(/_  We ARE all FREE> ingo@| |(_|o(_)| (_| 
http://www.2b1.de/Rebol/                     ._|      ._|

Reply via email to