[jawsscripts] Re: decimal points?

  • From: "Paul Magill" <magills@xxxxxxxxxxx>
  • To: <jawsscripts@xxxxxxxxxxxxx>
  • Date: Sat, 13 Dec 2008 23:37:18 +1100

Hi Martin,

The below should do what you want.  You will need to tidy up the output 
though.

It is a modified extract, from a group of scripts I use at work for various 
calculations with Dollar & cents, thus the requirement for decimals.

To increase the accuracy, just increase the multiplier & divider values. e 
g. multiplier from 1000 to 100000 and the divider from 100 to 1000.
* keep in mind though, the upper limit of the 4 byte integer of Jaws, around 
1000,000,000 I think.


String Function SimpleDecimalDivide (int InitialValue, int Divisor)

var

INT IntermediateValue,

STRING ResultString,

STRING DecimalString

; presumes 2 decimal place accuracy required

LET IntermediateValue = (InitialValue * 10000) / Divisor

LET ResultString = IntToString (IntermediateValue / 100) ; gives the whole 
number portion of the result

LET DecimalString = IntToString (IntermediateValue % 100) ; gives the 
decimal portion of the result

LET ResultString = ResultString + "." + DecimalString

Return (ResultString)



EndFunction





Script TestOnF8 ()

SayString (SimpleDecimalDivide (5, 13))

EndScript


Regards,
Paul from Aust
----- Original Message ----- 
From: "Martin" <martinfc@xxxxxxxxxx>


As they say, when it rains?
I want to performa simple calculation to get a percentage.
For example, (5/13)*100 is supposed to give me 38.46%.  But because Jaws
takes off any decimal, I get 0 every time.
Am I stepping out of the Jaws scripting limits here?
I'm using the script language to create a report and maybe it's just too
ambitious.
Cheers,
martin


__________ 
Visit and contribute to The JAWS Script Repository http://jawsscripts.com

View the list's information and change your settings at 
//www.freelists.org/list/jawsscripts

Other related posts: