SuperBasic: optional parameters that will work with QLiberator?
Posted: Tue Feb 15, 2022 7:06 pm
Hi,
this might be an incredibly stupid question but for the life of me I can't figure out if it is possible to implement optional parameters in SuperBasic. What I mean is something along these lines:
And then being able to call foo with just one parameter:
And since goo$ is passed in as empty/undefined then it would be set to the default value.
Toolkit II has PARSTR$ which lets me implement what I want this way:
BUT this will not work if I compile it since QLIb does not support PARSTR$ or PARNAM$
Are there any extensions or clever tricks in SuperBasic to check for undefined/empty parameter?
Thanks in advance for any tips or pointers to docs!
this might be an incredibly stupid question but for the life of me I can't figure out if it is possible to implement optional parameters in SuperBasic. What I mean is something along these lines:
Code: Select all
def proc foo(bar$,goo$)
REM This I don't know how to do:
if is_empty(goo$) then goo$="default value"
end def
Code: Select all
foo "val_for_bar$"
Toolkit II has PARSTR$ which lets me implement what I want this way:
Code: Select all
def proc foo(bar$,goo$)
g$=PARSTR$(goo$,2)
if g$='' then g$='default value'
....
Are there any extensions or clever tricks in SuperBasic to check for undefined/empty parameter?
Thanks in advance for any tips or pointers to docs!