math operations
[1/6] from: john:thousand-hills at: 3-Aug-2001 19:50
I have an HTML form serving numeric fields to a REBOL script and everything
works fine, until I attempt any minor math function. It is reading the
fields as a string.
All these codes returned the variables set from the HTML, and failed at the
multiplication with an error message that there is no value data is a string.
_______________
a: cgi/a
b: cgi/b
print a
print b
print multiply a b <-- failed here
________________
a: cgi/a
b: cgi/b
print a
print b
sum: func [a b] [a * b] <--failed here
sum a*b
____________________
Any help?
john
[2/6] from: carl:cybercraft at: 4-Aug-2001 13:34
On 04-Aug-01, john wrote:
> I have an HTML form serving numeric fields to a REBOL script and
> everything works fine, until I attempt any minor math function. It
<<quoted lines omitted: 17>>
> ____________________
> Any help?
Convert your values to decimals or integers? ie...
a: to-decimal cgi/a
> john
--
Carl Read
[3/6] from: john::thousand-hills::net at: 3-Aug-2001 23:03
This is not easy to find in the book, thank you Carl..
John
At 01:34 PM 8/4/2001 +1200, you wrote:
[4/6] from: tomc:darkwing:uoregon at: 4-Aug-2001 10:14
try
a: load cgi/a
b: load cgi/b
...
On Fri, 3 Aug 2001, john wrote:
[5/6] from: sanghabum:aol at: 4-Aug-2001 14:21
[tomc--darkwing--uoregon--edu]:
> try
>
> a: load cgi/a
> b: load cgi/b
> ...
>
To reiterate the point Jeff makes in Zine/4. better is:
a: mold/only load/all cgi/a
lest cgi/a contain some sneaky string like "rebol [quit]"
--Colin
[6/6] from: john:thousand-hills at: 5-Aug-2001 8:07
This worked, but is there a way to set 2 decimal places?
a: to-decimal cgi/a
b: to-decimal cgi/b
/john
At 10:14 AM 8/4/2001 -0700, you wrote:
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted