[Implemented] Optional Parameters in Procedures
Posted: Sat Jul 10, 2004 4:20 pm
One thing I miss in PureBasic is having optional parameters in Procedure calls. Look at these PB examples:
Optional parameters could be implemented by allowing them to have default values:
Code: Select all
Circle(x, y, Radius [, Color])
SaveImage(#Image, FileName$ [, ImagePlugin [, Flags]])
OpenWindow(#Window, x, y, InnerWidth, InnerHeight, Flags, Title$ [, ParentWindowID])
Code: Select all
Procedure Text(t$,x,y,Centered=#FALSE)
If Centered=#TRUE
x=((x-TextLength(t$))/2)
EndIf
Locate x,y : DrawText(t$)
EndProcedure
; 2 ways to call the above procedure
Text("hello",50,20)
Text("hello",320,20,#TRUE) ; centre text at position 320