Adding numbers (and limiting the result)

Sarah Reichelt sarahr at genesearch.com.au
Sun Dec 16 18:00:01 EST 2001


Try this:

on closefield
    put statRound(fld "Tot0" / fld "Grp0", 2) into fld "Cpp0"
end closefield

This will do your division, round the result to 2 decimals and then put that
answer into "Cpp0".

If you have a license &/or are not script-length restricted, you may find it
clearer (& easier to debug in the future) if you do this in 2 stages:

on closefield
    put fld "Tot0" / fld "Grp0" into theAnswer
    put statRound(theAnswer, 2) into fld "Cpp0"
end closefield


>> You could use numberFormat as suggested, or the round function.
>> 
>> put round(myNumber,2) into fld "Whatever"
>> 
>> This will give you 2 decimal places rounded by financial rules. If you want
>> statistical rounding rules, use the statRound function.
>> 
>> Cheers,
>> Sarah
> 
> Sarah,
> 
> Thanks for the suggestion, however I'm in the dark as to how to use this in
> my current script, for example this is the script in the field that
> generates the number that needs to be rounded:
> 
> on closefield
> put fld "Tot0" / fld "Grp0" into fld "Cpp0"
> end closefield
> 
> Should the statRound function go here, or in some other place?
> 
> Thanks!
> 
> 
> Michael McKenzie
> Director of Advertising
> Ruby-Gordon Inc.
> 
> 
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 




More information about the Use-livecode mailing list