item random() (was Random(3) often returns 1)
Rob Cozens
rcozens at pon.net
Fri Jun 9 10:38:02 EDT 2006
Geoff, et al:
> Even stranger, making this slight adjustment fixes it:
>
> on mouseUp
> repeat 1000
> put random(3) into z
> add 1 to x[z]
>
There is something problematic involved in referencing a function
result as a variable inline in a statement. I have encountered
instances in other handlers where logic something like:
add functionY(aValue) to anotherVariable
get mod(functionZ(anotherValue),2)
send "doWhatUDo"&&functionX(value1,value2) to button buttonName
failed to produce the correct result. Generally, if not always,
evaluating the function into a variable and then referencing the
variable works. I've never tracked down the "why"; but the fix seems
to work reliably.
If anyone is curious, you might try:
add 1 to x[(random(3))]
add 1 to x[value(random(3))
add 1 to x[(value(random(3)))
add 1 to item (random(3)) of myCounter]
add 1 to item value(random(3)) of myCounter
add 1 to item (value(random(3))) of myCounter
Rob Cozens
CCW, Serendipity Software Company
"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."
from "The Triple Foole" by John Donne (1572-1631)
More information about the use-livecode
mailing list