Page 1 of 1

What is wrong with this code?

Posted: Wed Mar 05, 2008 2:46 am
by Tom
on mouseDown
local x=totalDistance,y=totalDuration
multiply x by 3600
divide y by x
set the label of me to y
end mouseDown

totalDistance and totalDuration are both numbers.

The error message is:
Type multiply: destination has a bad format (numeric?)
Object TotalSpeed
Line multiply x by 3600
Hint mouseDown

I assume the 'destination' is x.

Posted: Wed Mar 05, 2008 3:20 am
by Mark
Hi Tom,

The variables totalDistance and totalDuration don't appear to be defined. If you add the line

put totalDistance

to the script, does the message box contains "totalDistance" or a number after running the script?

Best,

Mark

Maths

Posted: Wed Mar 05, 2008 7:49 am
by bjb007
Tom

Not sure what you're trying to do here.
Do you want miles/hour or seconds/mile?
Only guessing as "3600" is number of
seconds in an hour.

Apart from giving the two variables values
you need to multiply time x 3600, not
distance.

This should work:

on mouseDown
put field fldx into x --input field for x
put field fldy into y --input field for y
multiply y by 3600
set the label of me to round(y/x,2) --round result to 2 decimals
end mouseDown