argCount: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page ArgCount to argCount: Converting page titles to lowercase)
m (Text replacement - "source>" to "syntaxhighlight>")
Line 14: Line 14:
<source lang="mtmacro" line>
<source lang="mtmacro" line>
argCount()
argCount()
</source>
</syntaxhighlight>




Line 25: Line 25:
[h,count(numArgs): total = total + arg(roll.count)]
[h,count(numArgs): total = total + arg(roll.count)]
[r: total]
[r: total]
</source>
</syntaxhighlight>





Revision as of 17:38, 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.

Once the number of arguments have been determined you can use arg() to retrieve them.

Usage

<source lang="mtmacro" line> argCount() </syntaxhighlight>

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]

</syntaxhighlight>

See Also