add: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
(New page: ==Function add== 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...)
 
mNo edit summary
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
==Function add==
{{Languages|add}}
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.
{{MacroFunction
|name=add
|trusted=false
|version=1.3.b48
|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: add(val1, val2, ...)]
[h: result = add(val1, val2, ...)]
[h: sum(val1, val2, ...)]
[h: result = sum(val1, val2, ...)]
[h: concat(val1, val2, ...)]
[h: result = concat(val1, val2, ...)]
</source>
</source>


===Examples===
|examples=
====Numbers====
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[r: add(1,4)]
[r: add(1,4)]
</source>
</source>
Returns 5.
Returns:<source lang="mtmacro" line start=2>5</source>


====Strings====
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[r: add("Mary", "had", "a", "little", "lamb")]
[r: add("Mary", "had", "a", "little", "lamb")]
</source>
</source>
Returns "Maryhadalittlelamb".
Returns:<source lang="mtmacro" line start=2>"Maryhadalittlelamb"</source>


====Numbers and Strings====
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[r: add(1,"4")]
[r: add(1,"4")]
</source>
</source>
Returns "14".
Returns:<source lang="mtmacro" line start=2>"14"</source>
 
}}
[[Category:Mathematical Function]]
[[Category:String Function]]
{{Languages|add}}

Revision as of 14:11, 31 July 2021

Languages:  English  • 日本語


add() Function

Introduced in version 1.3.b48
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

====Numbers====
[r: add(1,4)]
Returns:
5


Strings

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


Numbers and Strings

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

Languages:  English  • 日本語