[REBOL] Re: How? Read HTTP message body - err
From: arolls:bigpond:au at: 11-Aug-2001 13:12
> Oh yes, what's the [err] for on send-cmd? I can't get rid of it
> but it doesn't appear to do anything.
> send-cmd: function [buffer thecntr] [err]
> insert http-port join "HTTP/1.0 200 OK^/"
> "Content-type: text/html^/^/"
> "<br><pre>" buffer "</pre><br>"
> length? buffer "<br><br>" now/time " " thecntr
The first argument to the 'function function
is a block of user supplied arguments.
In this case, it is: [buffer thecntr].
The second argument is a block of local
words to use in the body of the function.
In this case, it is: [err].
Since we can see that 'err is not used in
the body, we can remove it, but we still
require a block here, so replace it with
an empty block; .
The third argument is the body, of course.
This is the change:
send-cmd: function [buffer thecntr] [err] [...]
send-cmd: function [buffer thecntr]  [...]
>> ? function
FUNCTION spec vars body
Defines a user function with local words.
FUNCTION is a function value.
spec -- Optional help info followed by arg words (and optional type and
string) (Type: block)
vars -- List of words that are local to the function (Type: block)
body -- The body block of the function (Type: block)
'function works slightly differently to 'func.
You could rewrite it using 'func:
send-cmd: func [buffer thecntr /local err][...]
or even better, with comments that document
what it does properly.
send-cmd: func ["I am a function that does something"
buffer "Your preformatted text"
/local err "not used at the moment"