Jump to content

[UDF]optional number of parameters


Recommended Posts

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@

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...