How to combine a string and a variable into one string?

Hei,

I would like to combine a string together with a variable.
I tried it this way:

Function Test()
string wavename = “wave”
variable number = 1
string together

together = wavename + number
Print together

End

I would like the Function to print “wave1” but it does not work. How can I do this?

Cheers,

Finn
Here are two solutions.


Function Test()
	String name = "wave"
	Variable number = 1
	
	// Simple solution
	String together = name + num2str(number)
	Print together
	
	// More powerful - see documentation for sprintf
	sprintf together, "%s%d", name, number
	Print together
End


sprintf is general and powerful. In this example it substitutes the contents of name for %s. It then converts number into text and substitutes that text for %d. It stores the result in together.

See the documentation for sprintf for details.