Hi Ladislav:
        Thanks, you got it! All I was doing was
using the wrong data type in the function arg.

Obviously, I am not entirely clear about the
distinction between "port" and "file" data types.

Can anyone enlighten me, or point me to the
documentation that will clarify for me?
regards :>) 
tim

At 11:13 AM 4/2/00 +0200, you wrote:
>Hi,
>
>----- Puvodní zpráva -----
>Od: <[EMAIL PROTECTED]>
>Komu: <[EMAIL PROTECTED]>
>Odesláno: 2. dubna 2000 7:33
>Predmet: [REBOL] [REBOL]Problem with function argument
>
>
>> Hello All:
>>
>> I am getting an error message when attempting
>> to pass a value as a argument to a user-defined
>> function:
>>
>> the error message is:
>> fprint expected fp argument of type: file.
>> ** Where: fprint fp "line one"
>>
>> code follows: thanks in advance to all!!
>> tim
>>
>> ; first the function
>> fprint: func [fp[file!] value[string!]]
>> [
>>   either not-equal? fp none
>>   [
>>     write/append fp value
>>     write/append fp newline
>>   ]
>>   [ print value ]
>> ]
>> fp: none
>> ; check for server name in cgi environment variables
>> either equal? system/options/cgi/server-name  none
>>
>
>>    ; value is empty, presume the script is run from commad line
>>    print "no server name, application run from console"
>>    fp: open/new/write %hello.htm
>> ]
>> ; script is invoked via server, yes, I know we need
>> ;   a content-header string, etc here.
>>
>
>>   prin "Server name: "
>>   print system/options/cgi/server-name
>> ]
>> ; call function
>> fprint fp "line one" ; rebol doesn't like this
>> ; if the file has been opened, close it
>> if not-equal? fp none [close fp]
>>
>
>The header of your function should probably be as follows:
>
>fprint: func [fp[port! none!] value[string!]]
>
>to allow open ports and none as the valid arguments.
>
>Moreover, the following:
>
>>   either not-equal? fp none
>>   [
>>     write/append fp value
>>     write/append fp newline
>>   ]
>>   [ print value ]
>> ]
>
>
>will not work for ports. You can change it to:
>
>either fp [
>    append fp value
>    append fp newline
>] [print value]
>
>Regards,
>    Ladislav
>
>
>

Reply via email to