extends lbx as desktoplistbox, db as database, str as string, deleteall as boolean, txtencoding as textencoding = nil
and it works fine.
i want to change to this one:
extends lbx as desktoplistbox, db as database, str as string, deleteall as boolean, txtencoding as textencoding = Encodings.UTF8
but i got this error:
A constant was expected here, but this is some other kind of expression
what’s the correct what to write this kind of parameters, and where it is on documentation, for further looking?
You cannot use anything other than a constant as a default, and Encodings.XXX are not constants.
Instead, if you never actually need or want the encoding to be nil, do this at the top of your method:
if txtencoding is nil then
txtencoding = Encodings.UTF8
end if
Other alternatives:
Create a differently named method that does not ask for txtencoding and simply use UTF8.
Remove the default from this method and create a second version that does not include that parameter at all. The new method will call the first with txtencoding = UTF8. So if you specify it, even as nil, it will use that. If you don’t specify it, it will default to UTF8.