Comma seperated number

BlitzMax Forums/BlitzMax Beginners Area/Comma seperated number

The Forum Archive is locked. These are the original blitzbasic.com forums, kept so their posts can still be read and searched. No new topics, replies or edits can be made here. To join the conversation, head over to the Blitz3D+ forums.

Here's my solution...
Function FormatNumber:String(num:String)
	Local i:Int=num.Length-1,j:Int=0,out:String
	Repeat
		out=Chr(num[i])+out
		i:-1
		j:+1
		If j=3 And i>=0 Then
			out=","+out
			j=0
		EndIf
	Until i<0
	Return out
EndFunction

Local num:Int=1

For Local i:Int=1 Until 11
	Print FormatNumber(num)
	num:*10
Next

No need for seperate functions for numbers or strings, as they will all get converted to a string when passed to the function.