Math problem

Bob Sneidar bobs at twft.com
Mon Feb 13 17:09:12 EST 2012


Hey there it is! I was looking for a strictly mathematical method but that will do nicely. 

Bob


On Feb 13, 2012, at 12:48 PM, Paul Dupuis wrote:

> FUNCTION countTheHours2 pStartTime, pEndTime, pIncrement
>    IF pIncrement is empty THEN put 900 into pIncrement -- pIncrement is
> in seconds. So 900 is 15 minutes. Do not use zero. 1 is minimum.
> 
>    TRY
>        convert pStartTime to seconds
>        convert pEndTime to seconds
>        put (round(((pEndTime - pStartTime) / pIncrement),0) /
> (3600/pIncrement)) into theResult
>        -- take the difference in pIncrement units, rounded up and
> divided by number of increments per hour to get hours
>    CATCH theError
>        put "ERROR: Not a valid time!" into theResult
>    END TRY
> 
>    return theResult
> END countTheHours2
> 
> On 2/13/2012 3:12 PM, Bob Sneidar wrote:
>> FUNCTION countTheHours pStartTime, pEndTime, pIncrement
>>    IF pIncrement is empty THEN put 0 into pIncrement
>> 
>>    TRY
>>        convert pStartTime to seconds
>>        convert pEndTime to seconds
>>        put ((pEndTime - pStartTime) / 3600) into theTotalTime -- decimal hours
>>        put (theTotalTime div pIncrement) * pIncrement into theResult -- integer hours
>>        put theTotalTime mod pIncrement into theModulus -- modulus 
>>        IF theModulus is not 0 THEN add pIncrement to theResult
>>    CATCH theError
>>        put "ERROR: Not a valid time!" into theResult
>>    END TRY
>> 
>>    return theResult
>> END countTheHours
> 
> -- 
> Paul Dupuis
> Cofounder
> Researchware, Inc.
> http://www.researchware.com/
> http://www.twitter.com/researchware
> http://www.facebook.com/researchware
> http://www.linkedin.com/company/researchware-inc
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list