argCount: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
m (Text replacement - "<source" to "<syntaxhighlight") |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 3: | Line 3: | ||
|version=1.3b51 | |version=1.3b51 | ||
|description= | |description= | ||
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 | 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 | call any of the existing functions. You can then use the {{code|argCount()}} function to determine how many arguments were passed | ||
Line 12: | Line 12: | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
argCount() | argCount() | ||
</ | </syntaxhighlight> | ||
Line 20: | Line 20: | ||
An example of a simple macro that would be defined as a user defined function. This function will add together | 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. | all of the arguments that are passed to it. | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[h: numArgs = argCount()] | [h: numArgs = argCount()] | ||
[h: total = 0] | [h: total = 0] | ||
[h,count(numArgs): total = total + arg(roll.count)] | [h,count(numArgs): total = total + arg(roll.count)] | ||
[r: total] | [r: total] | ||
</ | </syntaxhighlight> | ||
Line 31: | Line 31: | ||
[[defineFunction|defineFunction()]], [[isFunctionDefined|isFunctionDefined()]], [[arg|arg()]] | [[defineFunction|defineFunction()]], [[isFunctionDefined|isFunctionDefined()]], [[arg|arg()]] | ||
}} | }} | ||
[[Category: | [[Category:User Defined Function]] |
Latest revision as of 18:34, 14 March 2023
argCount() Function
• Introduced in version 1.3b51
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]