Jump to content
Sign in to follow this  
ATnightAT

[UDF]optional number of parameters

Recommended Posts

ATnightAT

Good morning...

I'd like to know, how i could write a function with a optional number of parameters...

I can't express it more precisely, because my english isn't very well^^

A Example would be BitOR(). You can call this function with infinite parameters.

mfg

@night@

Share this post


Link to post
Share on other sites
Yashied
99ojo

Hi,

i try to make as simple as i can and i hopefully understand what you mean.

You can define default parameters in function call.

mymsgbox ()
mymsgbox ("my title", "my text")

_mymsgbox ("_my msgbox")
_mymsgbox ("_my msgbox", "_my text")
;_mymsgbox () would cause an error

Func mymsgbox ($title = "no title", $text = "no text")
    MsgBox (0, $title, $text)
EndFunc

Func _mymsgbox ($title, $text = "no text")
    MsgBox (0, $title, $text)
EndFunc

;-))

Stefan

Edited by 99ojo

Share this post


Link to post
Share on other sites
ATnightAT

Thank you!

It's a pity, that @NumParam doesn't work...

Then i've to use the array...

mfg

@night@

Share this post


Link to post
Share on other sites
KaFu

It's a pity, that @NumParam doesn't work...

Where did you read that?

Test(1,1,1,1,1,1)
Func Test($v1 = 0, $v2 = 0, $v3 = 0,$v4 = 0,$v5 = 0,$v6 = 0,$v7 = 0,$v8 = 0,$v9 = 0,$v10 = 0)
     For $i = 1 To @NumParams
         ConsoleWrite("Param #" & $i & "= " & Eval("v" & $i) & @CRLF)
     Next
 EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.