Suggestion - default values for functions

Previous topic - Next topic

PeeJay

When passing values to functions, is it possible to have default values, Gernot?

To give a simple example, currently we have to use:

Code (glbasic) Select
DoText(50,50,"No Default Text Allowed","","","","","")
DoText(100,100,"This is ","some text ","to draw.","","","")
DoText(100,150,"This ","is some more.","","","","")
SHOWSCREEN
KEYWAIT

FUNCTION DoText: x,y,a$,b$,c$,d$,e$,f$
a$=a$+b$+c$+d$+e$+f$
PRINT a$,x,y
ENDFUNCTION
but if you replaced that with a system that allowed default values, it becomes:

Code (glbasic) Select
DoText()
DoText(100,100,"This is ","some text ","to draw.")
DoText(100,150,"This ","is some more.")
SHOWSCREEN
KEYWAIT

FUNCTION DoText: x=50,y=50,a$="Default Text",b$="",c$="",d$="",e$="",f$=""
a$=a$+b$+c$+d$+e$+f$
PRINT a$,x,y
ENDFUNCTION
where b$,c$,d$,e$,f$ would automatically by null unless a string was passed to them.
a$ would be "Default Text" unless a string was passed to it.
x and y would be 50 unless values were passed to them.
www.peejays-remakes.co.uk
For games, remakes, and GL Basic Tutorials
Artificial Intelligence is no match for Natural Stupidity

Kitty Hello

I know. I have to do this. Sigh.