Can’t find any mention in the help file, but it looks like methods you add to the xojoscript context class can’t have optional parameters.
Running a script with a method call leaving out the optional parameter results in an error about not enough parameters.
If this correct or am I missing something?
EDIT: God damn it’s annoying that you need to first click the correct subforum and then select the subforum again or the message will be posted in the wrong forum, this happens frequently if I forget, this one should have been in “general”
What is the method definition look like?
Just an example:
ParseString(strSource As String, strDelim As String = " ")
Calling this in the script like so:
s = ParseString(strTest)
Results in “Not enough parameters”
I tried with
ParseString(strSource As String, [i]Optional[/i] strDelim As String = " ")
But same thing.
Then have two methods:
Sub ParseString(strSource As String)
ParseString(strSource, " ")
Sub ParseString(strSource As String, strDelim As String)
Does it work like so:
ParseString(strSource As String, Optional strDelim As String)
Thanks all, I’ll try the suggestions once I get some coffee in me
Forgot to update this one, got sidetracked…
Just using Optional instead of specifying a default doesn’t work either, seems xojoscript doesn’t like optional/default parameters.
Within a script it works - it apparently doesn’t work on the Context object.
i’m overloading the method,that is: same method but with more parameters. afaik this is the only way you can do something similar to ‘optional’ params from xojoscript.
Yeah that’s how I’ve done it now.
No biggie, where there’s a will there’s a way
FWIW, I’ve created a feature request for this: