Navigation: thinBasic language > Script structure > Functions/Subs > FUNCTION Default parameter value |
|
Starting from thinBasic version 1.3.0.1 it is possible to indicate default value for function parameters passed BYVAL.
So far it is possible to indicate default value only for numeric parameters passed BYVAL. More options will come.
An example can explain it:
USES "console"
'---Define a function with 2 mandatory BYVAL params having default values
' 3rd param is optional again with default value
' 4th param is again optional but no default value so its value in function will be 0 if not passed
Function MyFunction(p1 As Long = 100, p2 As Long = 200, Optional p3 As Long = -1, p4 As QUAD)
console_writeline p1, p2, p3, p4
End Function
console_writeline "--- many possible ways to call functions are now available"
MyFunction(,)
MyFunction(,,)
MyFunction(,,2000)
MyFunction(,123,2000)
MyFunction(765,,2000)
MyFunction(765,,-150, 45)
console_waitkey
© 2004-2008 thinBasic. All rights reserved. | Version 1.7.0.0 | Web Site: http://www.thinbasic.com |