optional variables

BlitzPlus Forums/BlitzPlus Programming/optional variables

rdodson41(Posted 2004) [#1]
Is there a way in B+ to have optional variables in functions? Like a vairable that the user can set when calling the function, but if it isn't set defaults to a predetermined value?


soja(Posted 2004) [#2]
Yes. Here's an example:
Out("Hello")
Out("Twice", 2)
WaitKey

Function Out(s$, count%=1)
	For i = 1 To count
		Print s$
	Next
End Function

Just make sure the optional parameters are specified after the others.


rdodson41(Posted 2004) [#3]
Nice thanks, thats just what i needed.