listGet: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 6: | Line 6: | ||
|usage= | |usage= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
listGet(list, index) | listGet(list, index) | ||
</ | </syntaxhighlight> | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
listGet(list, index, delim) | listGet(list, index, delim) | ||
</ | </syntaxhighlight> | ||
If delim is not specified then the default value of ',' is used as the value separator in the [[Macros:string list|string list]] | If delim is not specified then the default value of ',' is used as the value separator in the [[Macros:string list|string list]] | ||
|example= | |example= | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[r: listGet("This, is, a , test", 2)] | [r: listGet("This, is, a , test", 2)] | ||
</ | </syntaxhighlight> | ||
Returns {{code|a}} | Returns {{code|a}} | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[r: listGet("This: is: a :test", 1, ":")] | [r: listGet("This: is: a :test", 1, ":")] | ||
</ | </syntaxhighlight> | ||
Returns {{code|is}} | Returns {{code|is}} | ||
===Known Bug=== | ===Known Bug=== | ||
If you use a whitespace character like a SPACE or TAB, listGet can pull the wrong indexed value. | If you use a whitespace character like a SPACE or TAB, listGet can pull the wrong indexed value. | ||
< | <syntaxhighlight lang="mtmacro" line> | ||
[h: list = "0 1 3 4"] | [h: list = "0 1 3 4"] | ||
[r: listGet(list, 3, " ")] | [r: listGet(list, 3, " ")] | ||
</ | </syntaxhighlight> | ||
The output should be 3, but it is 4 because of the two SPACE characters being treated as one. Consequently this skips over an empty entry. | The output should be 3, but it is 4 because of the two SPACE characters being treated as one. Consequently this skips over an empty entry. | ||
}} | }} | ||
[[Category:String List Function]] | [[Category:String List Function]] |
Latest revision as of 23:59, 15 March 2023
listGet() Function
• Introduced in version 1.3b42
Returns the value in the string list at the specified index. The index for a string list starts at 0.
Usage
listGet(list, index)
listGet(list, index, delim)
If delim is not specified then the default value of ',' is used as the value separator in the string list
Example
[r: listGet("This, is, a , test", 2)]
Returns a
[r: listGet("This: is: a :test", 1, ":")]
Returns is
Known Bug
If you use a whitespace character like a SPACE or TAB, listGet can pull the wrong indexed value.
[h: list = "0 1 3 4"]
[r: listGet(list, 3, " ")]