Can functions not return strings?

BlitzPlus Forums/BlitzPlus Programming/Can functions not return strings?

indietom(Posted 2014) [#1]
Hi!

I was trying to make a function takes an int and returns the roman number as a string but the function just returns a 0.

 Function toRoman(num)

	Local number$ = ""
	
	If num >= 10 Then
		number = "X" + toRoman(num-10)
		Return number
	End If
	If num >= 9 Then
		number = "IX" + toRoman(num-9)
		Return number
	End If
	If num >= 5 And killFunc = False Then
		number = "V" + toRoman(num-5)
		Return number
	End If
	If num >= 4 Then
		number = "IV" + toRoman(num-4)
		Return number
	End If
	If num >= 1 Then
		number = "I" + toRoman(num-1)
		Return number
	End If
	
	Return number$
	
End Function 


Thanks for any help


Floyd(Posted 2014) [#2]
Function names are just like variable names.

The variable number$ is a string, and so is the value of the function toRoman$(num).


indietom(Posted 2014) [#3]
Thanks for the help.