Adding numbers (and limiting the result)
sarahr at genesearch.com.au
Sun Dec 16 18:00:01 EST 2001
put statRound(fld "Tot0" / fld "Grp0", 2) into fld "Cpp0"
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:
put fld "Tot0" / fld "Grp0" into theAnswer
put statRound(theAnswer, 2) into fld "Cpp0"
>> 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.
> 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?
> Michael McKenzie
> Director of Advertising
> Ruby-Gordon Inc.
> use-revolution mailing list
> use-revolution at lists.runrev.com
More information about the Use-livecode