Optional parameters for WHAT?
I think he means Subs cannot have optional parameters.
In Delphi procedures you can have default values for parameters.
The way it would look in B4A is:
'All 3 parameters have default values and are optional
sub SumAll(Value1=0 as int, Value2=0 as int, Value3=0 as int) as Int
return Value1 + Value2 + Value3
end sub
'If a parameter has a default value, the argument is optional in the calling rtn.
'It can be called using:
x = SumAll()
x = SumAll(123)
x = SumAll(123,456)
x = SumAll(123,456,789)
Optional parameters can only appear
after required parameters.
So the following is legal:
'The first parameter is NOT optional so you must call SumAll with at least one argument:
sub SumAll(Value1 as int, Value2=0 as int, Value3=0 as int) as Int
return Value1 + Value2 + Value3
end sub
'In the calling rtn:
x = SumAll() 'This gives syntax error because Value1 parameter is not optional because it does not have a default value.
x = SumAll(123) 'This works
x = SumAll(123,456) 'This works
x = SumAll(123,456,789) 'This works
I would love to see this in B4X.
I use it all the time in Delphi.