If an optional parameter is omitted in the midle of a function, you have to add an extra comma, so why not
ask Ruud to make a stricter syntaxchecking for UDF's, personally i would like that to be an option:
Strict On/OffExample, Function DoSomeThing($a,Optional $b, Optional $c):
This is legal(Strict Off, normal way of KiXtart):
$Res = DoSomeThing($a,$b,$c)
$Res = DoSomeThing($a,$b)
$Res = DoSomeThing($a,,$c)
$Res = DoSomeThing($a)
Whith a stricter syntax checking it should read like this, to be accepted(Strict On):
$Res = DoSomeThing($a,$b,$c)
$Res = DoSomeThing($a,$b,)
$Res = DoSomeThing($a,,$c)
$Res = DoSomeThing($a,,)
I just found cj's idea so good, that i have made this for my UDF liblary:
code:
Function SubString($String, $Start, Optional $Len)
$SubString = ""
If VarType($String) <> 8
Return
EndIf
If VarType($Start) <> 3
Return
EndIf
If VarType($Len) <> 3
$Len = Len($String) - $Start + 1
EndIf
$SubString = SubStr($String, $Start, $Len)
EndFunction
Erikrhowarth and Fuse, what do you think about this idea! (Of course Ruud would have to agree in making this option)