Hey all, I need someone to help jog my memory.
I seem to remember reading somewhere that it is possible to declare optional arguments which can be passed to a function, but which can be omitted; in which case the function uses the default value. I can't find that text again, now that I need the ability. (Was it in GLbasic?)
It would look something like: (Just a quick and dirty example..)
FUNCTION Example: x%,y%, [color% = 0] //where color% can either be passed, or not, by the calling program.
SETPIXEL x,y,color
ENDFUNCTION
If memory serves, optional arguments are allowed provided they are placed at the end of the declaration.
I COULD create two or more variations on the same function, or create nesting wrappers around the functions, but why create two when one will do?
Can someone give me a hand? :)
-CW
You do something like
FUNCTION a%:t%=1,t2%=5
ENDFUNCTION
You can then do :
g=a()
g=a(1)
g=a(2,3)
Thanks Mr.Toad, that's just what I was looking for.
I was adding a lot of extra garbage which I didn't need.
Cheers! :happy:
-CW