try something like this...
on randomcalculation
Operatorlist = ["+", "-", "*", "/"]
commandString = "put"
repeat with a = 1 to 4
commandString = commandString&&(random(10))&".0"
commandString = commandString&&Operatorlist[random(4)]
end repeat
commandString = commandString&&(random(10))&".0"
put commandString
do commandString
end
When used through the message window, the reult looks like this
-- "put 7.0 * 8.0 / 1.0 + 9.0 / 7.0"
-- 57.2857
-- "put 8.0 + 7.0 + 10.0 * 9.0 * 3.0"
-- 285.0000
-- "put 2.0 - 3.0 / 2.0 * 10.0 * 4.0"
-- -58.0000
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Dion Nicholas
> Sent: 20. kesakuuta 2001 14:46
> To: Lingo-L
> Subject: <lingo-l> Random Operators
>
>
> Hi,
>
> I'm hopeing someone can offer some insight into the following
> problem: I'm working on a behaviour that makes a random sum,
> eg. 7 + 3 - 2 = 8. I've managed to put random numbers into their
> places and do the calculation by hard coding the operators.
>
> How can I set-up a list that generates random operators and then
> inserts them into gmyTotal to replace the hard coded versions?
>
> This is what I have so far:
>
>
> global gmyTotal
>
> on makeSum
>
> set valueOne = string(random(10))
> set valueTwo = string(random(10))
> set valueThree = string(random(10))
>
> set gmyTotal to integer(valueOne + valueTwo - valueThree)
>
>
> set the text of field "display1" to string(valueOne)
> set the text of field "display2" to string(valueTwo)
> set the text of field "display3" to string(valueThree)
> set the text of field "total" to string(gmyTotal)
>
> end makeSum
>
>
> Thanks, Dion.
>
>
>
> [To remove yourself from this list, or to change to digest mode, go to
> http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
> email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
> Lingo-L is for learning and helping with programming Lingo. Thanks!]
>
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]