In servoy, can we create "Optional" parameter for method? Pls see below code for more details:
Function fDouble (Optional A)
If IsMissing(A) Then
fDouble = 1
Else
fDouble = A * 2
End If
fDouble(24)
var A = arguments[0]; // receive the (first) argument
if (!A)
{
...
}
method('a', 'b', 'c')
arguments[0] = 'a'
arguments[1] = 'b'
arguments[2] = 'c'
method('a', null, 'c')
var arg1 = arguments[0]
var arg2 = ''
if(arguments[3] == undefined)
{
var arg3 = arguments[1]
}
else
{
var arg3 = arguments[2]
arg2 = arguments[1]
}
method('a', null, 'c')
function myFunction(arg1, arg2, arg3) {
arg3 = arg3||'My Default Value'; // if (false/empty/0/null/undefined) then use the default value
// rest of your code...
}
Users browsing this forum: No registered users and 38 guests