49 lines
2.1 KiB
Plaintext
49 lines
2.1 KiB
Plaintext
local fn commatize( s as Str255, sep as Str255, start as long, stp as long )
|
|
|
|
if sep[0] == 0 then sep = ","
|
|
if start == 0 then start = 1
|
|
if stp == 0 then stp = 3
|
|
|
|
long i, j, k, l = len$(s)
|
|
|
|
for i = start to l
|
|
if ( asc( mid$( s, i, 1 ) ) >= asc("1") and asc( mid$( s, i, 1) ) <= asc("9") )
|
|
for j = i + 1 to l + 1
|
|
if ( j > l )
|
|
for k = j - 1 - stp to i step -stp
|
|
s = mid$( s, 1, k ) + sep + mid$( s, k + 1, l - k + 1 )
|
|
l = len$(s)
|
|
next k
|
|
exit for
|
|
else
|
|
if ( asc( mid$( s, j, 1 ) ) < asc("0") or asc( mid$( s, j, 1 ) ) > asc("9") )
|
|
for k = j - 1 - stp to i step -stp
|
|
s = mid$( s, 1, k ) + sep + mid$( s, k + 1, l - k + 1 )
|
|
l = len$(s)
|
|
next k
|
|
exit for
|
|
end if
|
|
end if
|
|
next j
|
|
exit for
|
|
end if
|
|
next i
|
|
print s
|
|
end fn
|
|
|
|
window 1
|
|
|
|
fn commatize("pi=3.14159265358979323846264338327950288419716939937510582097494459231" , " " , 6, 5 )
|
|
fn commatize("The author has two Z$100000000000000 Zimbabwe notes (100 trillion)." , "." , 0, 0 )
|
|
fn commatize("\'-in Aus$+1411.8millions\'" , "," , 0, 0 )
|
|
fn commatize("===US$0017440 millions=== (in 2000 dollars)" , "" , 0, 0 )
|
|
fn commatize("123.e8000 is pretty big." , "" , 0, 0 )
|
|
fn commatize("The land area of the earth is 57268900(29% of the surface) square miles." , "" , 0, 0 )
|
|
fn commatize("Ain't no numbers in this here words, nohow, no way, Jose." , "" , 0, 0 )
|
|
fn commatize("James was never known as 0000000007" , "" , 0, 0 )
|
|
fn commatize("Arthur Eddington wrote: I believe there are 15747724136275002577605653961181555468044717914527116709366231425076185631031296 protons in the universe.", ",", 0, 0 )
|
|
fn commatize(" $-140000±100 millions." , "" , 0, 0 )
|
|
fn commatize("6/9/1946 was a good year for some." , "" , 0, 0 )
|
|
|
|
HandleEvents
|