Hi Donal.
> what I'm trying to do is add two numbers passed on this query string
>
> sum.r?num1=3&num2=5
>
> and i'm getting this error
>
> ** Script Error: Cannot use add on string! value. ** Where: cgi/num1 +
> cgi/num2
>
> and this is the code I'm using
> ********************************** start code **************
> print "Content-Type: text/html^/" ;-- Required Page Header
> cgi: make object! decode-cgi system/options/cgi/query-string
> print [
> <html><body><h2>"CGI Results:"</h2>
> "result =" cgi/num1 + cgi/num2
> </body><html>
> ]
> ********************************** end code **************
>
> is the problem on line 2 ?
> or is it something more simple
I think there's something more to say:
Advices with to-integer was good, but what if someone will not
write good arguments (as sum.r?foo=bar instead sum.r?num1=3&num2=5).
... Error occured of course, because your object! cgi hasn't
cgi/num1 and cgi/num2.
or if there will be something like sum.r?num1=a&num2=b.
You will get then
cgi/num1: "a"
>> to-integer cgi/num1
** Script Error: Invalid argument: a.
** Where: make integer! value
Here is solution:
tmp!: make object! [num1: "" num2: ""]
this makes "template", solves first problem, num1 and num2 are always
defined in cgi object.
Next lines solve second problem:
cgi: make tmp! decode-cgi system/options/cgi/query-string
number: load cgi/number
digits: load data/digits
if all [integer? number integer? digits] [
...
]
Hope this Helps.
Jan
--
Jan Strejcek
[EMAIL PROTECTED]