off the top of my head, i guess you could create a function that gradually subtracted from each place of the number (recording how many times its subtracted) and then formatting the data into a string (idk if what im saying makes sense to you, so ill show u)
say u have:
money = 1,112,350
the function could start subtracting the ten millions place:
_money = money
_tenmillionsplace = 0
_millionsplace = 0
etc...
#tenmillionsplace
(_money - 10000000 >= 0) : _tenmillionsplace = _tenmillionsplace + 1; _money = _money - 10000000; goto "tenmillionsplace"
#millionsplace
(_money - 1000000 >= 0) : _millionsplace = _millionsplace + 1; _money = _money - 1000000; goto "millionsplace"
etc...
then when you got _money to be 0, you could format the number:
moneystring = format ["$%1%2,%3%4%5,%6%7%8", _tenmillionsplace, _millionsplace, _hundredthousandsplace, _tenthousandsplace, etc]
where the %1 would be equal to 0,
%2 = 1
%3 = 1
%4 = 1
%5 = 2
%6 = 3
%7 = 5
%8 = 0
then the variable moneystring would be equal to the string "$01,112,350"
this is just a basic idea that popped into my head, it may or may not work