home *** CD-ROM | disk | FTP | other *** search
- on addCommas xInt
- set finalString to string(xInt)
- set moreChars to (3 - (the number of chars in finalString mod 3)) mod 3
- repeat with i = 1 to moreChars
- put " " before finalString
- end repeat
- set groupsOfThree to []
- set groupCount to the number of chars in finalString / 3
- repeat with i = 0 to groupCount - 1
- set thisStart to i * 3
- set thisGroupString to EMPTY
- repeat with j = 1 to 3
- put char thisStart + j of finalString after thisGroupString
- end repeat
- add(groupsOfThree, thisGroupString)
- end repeat
- setAt(groupsOfThree, 1, string(value(getAt(groupsOfThree, 1))))
- set finalString to EMPTY
- repeat with i in groupsOfThree
- put i & " " after finalString
- end repeat
- delete char -30000 of finalString
- return finalString
- end
-
- on removeCommas xString
- set finalString to xString
- repeat with i = 1 to the number of chars in finalString
- set thisChar to char i of finalString
- if thisChar > "9" then
- return #error
- next repeat
- end if
- if thisChar < "0" then
- if thisChar = " " then
- delete char i of finalString
- next repeat
- end if
- return #error
- end if
- end repeat
- return finalString
- end
-
- on moneyToInteger xString
- set tempString to xString
- delete char 1 of tempString
- delete char 1 of tempString
- return integer(removeCommas(tempString))
- end
-
- on moneyFormat xInt
- set finalString to addCommas(xInt)
- put "DM " before finalString
- return finalString
- end
-