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.
What is wrong with this code?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
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
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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Maths
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
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
Life is just a bowl of cherries.