listReplace: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
Replaces the element at the specified index of a [[Macros:string list|string list]] with a new value. If a delimiter is not specified then the default value of ',' is used. The index for lists starts at 0
Replaces the element at the specified index of a [[Macros:string list|string list]] with a new value. If a delimiter is not specified then the default value of ',' is used. The index for lists starts at 0


|usage=
====Usage====
<source lang="mtmacro" line>
<source lang="mtmacro" line>
listReplace(list, index, value)
listReplace(list, index, value)
Line 13: Line 13:
</source>
</source>


====example====
====Example====
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[r: listReplace("This, isnt, a , test", 1, "is")]
[r: listReplace("This, isnt, a , test", 1, "is")]
Line 19: Line 19:
Returns This, is, a, Test
Returns This, is, a, Test


====example====
====Example====
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[r: listReplace("This: isnt: a: test", 1, "is", ":")]  
[r: listReplace("This: isnt: a: test", 1, "is", ":")]  
Line 25: Line 25:
Returns This: is: a: test
Returns This: is: a: test


====example====
====Example====
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: ListVar = "This, is, a, great, test"]
[h: ListVar = "This, is, a, great, test"]

Revision as of 23:37, 29 June 2009

listReplace() Function

Introduced in version 1.3b42
Replaces the element at the specified index of a string list with a new value. If a delimiter is not specified then the default value of ',' is used. The index for lists starts at 0

Usage

listReplace(list, index, value)
listReplace(list, index, value, delim)

Example

[r: listReplace("This, isnt, a , test", 1, "is")]

Returns This, is, a, Test

Example

[r: listReplace("This: isnt: a: test", 1, "is", ":")]

Returns This: is: a: test

Example

[h: ListVar = "This, is, a, great, test"]
[h: ListVar = listReplace(ListVar, 3, "silly")]
[r: ListVar]
Returns: This, is, a, silly, test

Usage

{{{usage}}}