What is wrong with this code?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Tom
Posts: 11
Joined: Wed Feb 13, 2008 10:25 pm

What is wrong with this code?

Post by Tom » Wed Mar 05, 2008 2:46 am

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.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed Mar 05, 2008 3:20 am

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 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

bjb007
Posts: 313
Joined: Fri Dec 28, 2007 4:56 am

Maths

Post by bjb007 » Wed Mar 05, 2008 7:49 am

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
Life is just a bowl of cherries.

Post Reply