Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Optional Function Arguments

Author
Message
Codger
23
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 13th Oct 2003 19:17
Is it possible to create Functions with optional arguments in the same manner as commands?

System
PIII 650 MZ H.P. Pavillion
394 Mem GeForce 4 400MX
CattleRustler
Retired Moderator
22
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 13th Oct 2003 19:57
I am not sure about that, prolly Ian will chime in with the answer. It would be nice tho-

Private MyFunction(Optional ByVal iNum as Integer)As Double
...yadda...
End Function

-RUST-
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th Oct 2003 20:26
Ding-dong ... that was me chiming in ... no? *sigh* Never mind

It's not possible to have optional arguments - even for commands.

What you can do for TPC commands and functions (not user functions) is redefine the same command several times with different parameters ... maybe sometime Lee will give the same ability to user functions
Codger
23
Years of Service
User Offline
Joined: 23rd Nov 2002
Location:
Posted: 13th Oct 2003 22:49
Thanks

I guess I can use some form of "null" variable and code inside the function to test if it really needed.

System
PIII 650 MZ H.P. Pavillion
394 Mem GeForce 4 400MX
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 13th Oct 2003 23:31 Edited at: 13th Oct 2003 23:31
Just make the first argument the number of used arguments that follow and fill in the optional values inside the function.

Login to post a reply

Server time is: 2026-07-27 22:40:57
Your offset time is: 2026-07-27 22:40:57