Hi Ed,

My ISP's mail server went done last night, and I was thus unable to send 
this.  Someone else has probably already helped you by now, but I'll send 
this anyway.

At 07:51 PM 8/27/2002 -0700, you wrote:
>OK, so what's going on here.
>
>I'm trying to put a little error handling around my application. If it 
>fails, I need it to send out an alarm. But, depending on the statement, I 
>get an error when trying to trap the error.
>
>For example, this works as expected:
>
> >> If Error? Fred: Try [ 1 / 0 ] [ Print "Whatever!" ]
>Whatever!
>
>As does this:
>
> >> If Error? Fred: Try [ 1 / 1 ] [ Print "Whatever!" ]
>== none
>
>This too:
>
> >> If Error? Fred: Try [ Print ] [ Print "Whatever!" ]
>Whatever!
>
>But this doesn't:
>
> >> If Error? Fred: Try [ Print "Get a grip!" ] [ Print "Whatever!" ]
>Get a grip!
>** Script Error: Fred needs a value
>** Near: If Error? Fred: Try [Print "Get a grip!"]
>
>This is confusing because why should I get an error on something that 
>doesn't and shouldn't cause an error.


Try returns either a value or error message from the block it evaluates.

print

because it lacks an argument returns an error message, which try passes on 
to Fred.

print ["Get a grip!"]

outputs a value to the console (thus fooling you), but actually _returns_ 
nothing (not even an error message, since there is no error); so try in 
turn is unable to put a value into Fred.  Rebol therefore cannot proceed 
past Fred.

After each of your lines type

fred

to see what fred now contains.

Enable try to actually return something and see what happens:

 >> If Error? Try [Fred: "Get a grip!" ] [ Print "Whatever!" ]
== none
 >> fred
== "Get a grip!"
 >>

At the console type

help <function-name>

If it doesn't say that the function returns something, then it probably 
doesn't.

hth,

Louis

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to