Function Syntax/Passing Variables

BlitzPlus Forums/BlitzPlus Programming/Function Syntax/Passing Variables

Adam Novagen(Posted 2006) [#1]
Yo, Blitz community,
ADAM here. I've been wondering something lately. I'm getting by with just the bottom-level 2D commands in Blitz 3D, and there are many commands that have optional parameters. For instance:

Graphics width,height[,depth][,mode]


And:

Rect x,y,width,height[,fill]


What I'm wondering is this: When you declare a function, like:

Function testfunc(num1,num2)

Print num1
Print num2

End Function


Is there a way to make one of the parameters, I.E. num1 or num2, optional, so that if you call the function later without all the parameters, you don't get a "Not enough parameters" error?


Yan(Posted 2006) [#2]
testfunc(100, 200)
testfunc(100)

end


Function testfunc(num1, num2=10)
  Print num1 + " : " + num2
End Function



Adam Novagen(Posted 2006) [#3]
THANK YOU, IAN!!!!! You have no idea how far that simple bit of code you gave me will go! (Ah, ah, ah, no hints - It'll come out soon enough! ;))