argCount: Difference between revisions
Jump to navigation
Jump to search
Verisimilar (talk | contribs) (Initial write-up.) |
No edit summary |
||
Line 1: | Line 1: | ||
{{MacroFunction | {{MacroFunction | ||
|name=argCount | |name=argCount | ||
|version=1.3b51 | |version=1.3b51 | ||
|description= | |description= | ||
The {{code|argCount()}} function is used to determine the number of arguments that have been passed to a user defined function. | |||
User functions are defined with the {{code|defineFunction()}}, once you have defined the function you can call it is you would | |||
call any of the existing functions. You can then use the {{code|argCount()}} function to determine how many arguments were passed | |||
when it was called. | |||
Once the number of arguments have been determined you can use [[arg|{{code|arg()}}]] to retrieve them. | |||
|usage= | |usage= | ||
Line 10: | Line 15: | ||
argCount() | argCount() | ||
</source> | </source> | ||
|example= | |||
An example of a simple macro that would be defined as a user defined function. This function will add together | |||
all of the arguments that are passed to it. | |||
<source lang="mtmacro" line> | |||
[h: numArgs = argCount()] | |||
[h: total = 0] | |||
[h,count(numArgs): total = total + arg(roll.count)] | |||
[r: total] | |||
</source> | |||
|also= | |also= |
Revision as of 11:49, 25 March 2009
argCount() Function
• Introduced in version 1.3b51
The
argCount()
function is used to determine the number of arguments that have been passed to a user defined function.
User functions are defined with the defineFunction()
, once you have defined the function you can call it is you would
call any of the existing functions. You can then use the argCount()
function to determine how many arguments were passed
when it was called.
arg()
to retrieve them.Usage
argCount()
Example
An example of a simple macro that would be defined as a user defined function. This function will add together
all of the arguments that are passed to it.
[h: numArgs = argCount()]
[h: total = 0]
[h,count(numArgs): total = total + arg(roll.count)]
[r: total]