Is it really this hard to print currency values?

Peter M. Brigham pmbrig at gmail.com
Mon Jul 30 15:53:34 EDT 2012


On Jul 30, 2012, at 11:28 AM, DunbarX at aol.com wrote:

> function digitToWord theDigits
>  put "One,Two,Three,Four,Five,Six,Seven,Eight,Nine" into ones
>  put "Ten,Eleven,Twelve,Thirteen,Fourteen,Fifteen,Sixteen,Seventeen,"¬
>  & "Eighteen,Nineteen" into teens
>  put ",Twenty,Thirty,Forty,Fifty,Sixty,Seventy,Eighty,Ninety" into tens
>  set numberformat to "#.00"
>  get offset(".",theDigits)
>  if it ‚ 0 then
>    put " Dollars and" && char it + 1 to it + 2 of theDigits & "/100" into
> temp
>    delete char it to it + 2 of theDigits
>  end if
> 
>  get number(chars of theDigits)
>  if char it - 1 of theDigits = 1 then put item char it of theDigits + 1 of
> teens before temp
>  else
>    put item char it of theDigits of ones before temp
>    put item char it - 1 of theDigits of tens & space before temp
>  end if
> 
>  if it „ 3 then put item char it - 2 of theDigits of ones && "Hundred" &
> space before temp
>  if it = 4 then put item char it - 3 of theDigits of ones && "Thousand" &
> space before temp
>  if it = 5 then put item char it - 4 of theDigits of tens && "Thousand" &
> space before temp
>  if it = 6 then
>    put item char 1 of theDigits of ones && "Hundred" && item char 2 of
> theDigits of tens && item char 3 of theDigits of ones & " Thousand " before
> temp
>  end if
> 
>  return temp
> end digitToWord

I think I lifted a similar handler from Hugh Senior some years ago and have been using it for years to print out receipts for copayments. Has been working like a charm.

-- Peter

Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig





More information about the use-livecode mailing list