using this i get the answer but not displayed in the right field.
Code: Select all
subtract the value of field "endfuel" from field "startfuel"
put the result into field "fuelused"
Cheers
Alex
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Code: Select all
subtract the value of field "endfuel" from field "startfuel"
put the result into field "fuelused"
Code: Select all
put 5 into oneNumber
put 2 into otherNumber
subtract otherNumber from oneNumber
--now oneNumber = 3 and otherNumber = 2
Code: Select all
put field 1 - field 2 / 60 into field 3
Code: Select all
--calculate time online
put field "timeonline" into ttimeonline
put the trunc of (ttimeonline) into tseconds
put the trunc of (tseconds /60/60) into thours
if thours < 1 then
put the trunc of thours into tminutes
end if
if tminutes < 1 then
put the trunc of thours & ":" & tminutes into field "totaltime"
end if
Code: Select all
on mouseUp
--calculate time online
-- this gives you the format for display e.g. "00:36:05"
set the numberformat to "00"
put field "timeonline" into tTimeonline
put tTimeOnline div (60*60) into tHours
subtract tHours * (60*60) from tTimeOnline
put tTimeOnline div 60 into tMinutes
subtract tMinutes * 60 from tTimeOnline
put tTimeOnline into tSeconds
-- leave out the seconds if you dont want them
put tHours & ":" & tMinutes & ":" & tSeconds into field "totaltime"
end mouseUp
Code: Select all
on mouseUp
-- assuming the seconds count is in fld 1
put timeOnLine(fld 1)
end mouseUp
function timeOnLine timeCalc
put trunc ((timeCalc/60)/60) into theHours
put ((timeCalc/60) mod 60) into theMinutes
set itemDel to "."
put item 1 of theMinutes into theMinutes
if theMinutes < 10 then put 0 & theMinutes into theMinutes
put theHours & "." & theMinutes into totalTime
return totalTime
end timeOnLine