That pointed me in the right direction, thanks.
function formatNumber(%num)
{
%len = strLen(%num);
if(%len < 4)
return %num;
if(striPos(%num,"-") == 0)
{
%negative = "-";
%num = getSubStr(%num,1,%len);
%len--;
}
while(%len > 3)
{
%formatted = "," @ getSubStr(%num,%len-3,%len) @ %formatted;
%num = getSubStr(%num, 0, %len - 3);
%len -= 3;
}
return %negative @ %num @ %formatted;
}
Works with up to 6-digit negatives down to -999,999 and numbers up to 2,147,483,647, which is until Torque appears to mess it up.