add: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
(Applied Template:MacroFunction)
Line 1: Line 1:
==Function add==
{{MacroFunction
Adds number and/or strings together. If all of the arguments to the function are numbers then a numeric addition is performed, if any of the arguments are strings then all of the arguments are concatenated as a string.
|name=add
|description=Adds number and/or strings together. If all of the arguments to the function are numbers then a numeric addition is performed, if any of the arguments are strings then all of the arguments are concatenated as a string.


===Usage===
|usage=
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: result = add(val1, val2, ...)]
[h: result = add(val1, val2, ...)]
Line 9: Line 10:
</source>
</source>


===Examples===
|examples=
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[r: add(1,4)]
[r: add(1,4)]
Line 24: Line 25:
</source>
</source>
Returns "14".
Returns "14".
}}

Revision as of 06:30, 6 March 2009

add() Function

Adds number and/or strings together. If all of the arguments to the function are numbers then a numeric addition is performed, if any of the arguments are strings then all of the arguments are concatenated as a string.

Usage

[h: result = add(val1, val2, ...)]
[h: result = sum(val1, val2, ...)]
[h: result = concat(val1, val2, ...)]

Examples

[r: add(1,4)]

Returns 5.

[r: add("Mary", "had", "a", "little", "lamb")]

Returns "Maryhadalittlelamb".

[r: add(1,"4")]
Returns "14".