you can use insertchar to insert something in the string
insertchar(<string>,<char>,<index>)
like this
function format_number;
mes format_number( "100000", "," );// display 100,000
close;
function format_number {
.@num$ = getarg(0);
.@format$ = getarg(1);
.@len = getstrlen( .@num$ );
for ( .@i = ( .@len%3 ? .@len%3 : 3 ); .@i < .@len; .@i += 4 ) {
.@num$ = insertchar( .@num$, .@format$, .@i );
.@len++;
}
return .@num$;
}
I forgot the function in the main repo..
//////////////////////////////////////////////////////////////////////////////////
// Returns a number with commas between every three digits.
// -- callfunc "F_InsertComma",<number>
// Examples:
// callfunc("F_InsertComma",7777777) // returns "7,777,777"
//////////////////////////////////////////////////////////////////////////////////
function script F_InsertComma {
set .@str$, getarg(0);
for (set .@i,getstrlen(.@str$)-3; .@i>0; set .@i,.@i-3)
set .@str$, insertchar(.@str$,",",.@i);
return .@str$;
}
it's better D: