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 Discussion / Default function parameters?

Author
Message
Radio Check
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location:
Posted: 29th Sep 2004 05:21
I know this probably doesn't exist, but just in case... is there a way that a function can be set up to either take a parameter or, on the absence of a parameter, use a default value?

ForInstance()
ForInstance(42)

function ForInstance(Val)
if not exist Val then Val = 24
endfunction

Making a cool sig is just too much pressure for me right now.
BatVink
Moderator
22
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 29th Sep 2004 05:54
No, I'm afraid not. The compiler will reject it.

BatVink
http://biglaugh.co.uk/catalog AMD 3000+ Barton, 512Mb Ram, 120 Gig Drive space, GeForce 5200 FX 128 Mb, Asus A7N8X Mobo.
Terms & Conditions apply
blanky
20
Years of Service
User Offline
Joined: 3rd Aug 2004
Location: ./
Posted: 29th Sep 2004 05:59
The closest thing, is you can let them pass 0 or a blank string ("").

By default, a non-existent variable is 0.

So, for example:

[BEGIN CODE]

tNum=36
print tNum
print nonExistentVar

[END CODE]

Which would come out with:

36
0

[img src=http://blanky.pt-web.net/ddd.gif] >::p

Login to post a reply

Server time is: 2025-05-24 21:32:31
Your offset time is: 2025-05-24 21:32:31