List Manipulation Functions: Difference between revisions

From wiki.jriver.com
Jump to navigation Jump to search
 
(30 intermediate revisions by 3 users not shown)
Line 69: Line 69:
The [[#ListClean|ListClean()]] function performs one of the operations specified by <i>mode</i> on the given <i>list</i>.
The [[#ListClean|ListClean()]] function performs one of the operations specified by <i>mode</i> on the given <i>list</i>.
The specified <i>delimiter</i> separates <i>list</i> items.
The specified <i>delimiter</i> separates <i>list</i> items.

Available <i>mode</i> values:


<div style="margin-left: 20pt;"><table style="border-spacing:0px; border-collapse:collapse; background: #f9f9f9">
<div style="margin-left: 20pt;"><table style="border-spacing:0px; border-collapse:collapse; background: #f9f9f9">
<tr><td style="text-align:left; padding-right:20pt"><b>1</b></td><td>Remove duplicates</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>1</b></td><td>Remove duplicates</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>2</b></td><td>Reverse the order of items</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>2</b></td><td>Reverse the order of items</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>3</b></td><td>Remove empty items</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>4</b></td><td>Trim (Removes any trailing delimiter)</td></tr>
</table></div>
</table></div>


Line 105: Line 109:
<tr><td style="text-align:left; padding-right:20pt"><b>0</b></td><td>Combine lists removing duplicates (order is preserved).</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>0</b></td><td>Combine lists removing duplicates (order is preserved).</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>1</b></td><td>Output only items contained in both lists (order is preserved).</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>1</b></td><td>Output only items contained in both lists (order is preserved).</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>2</b></td><td>Output only items NOT contained in both lists (order is preserved).</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>3</b></td><td>Output the first list without any values present in the second list (order is preserved).</td></tr>
</table></div>
</table></div>


Line 132: Line 138:
the output list would be <span style="font-family: monospace,monospace; font-size:1em;">Family\Mum; Family\Dad; Family\Gran; UK\Scotland\Edinburgh; UK\Scotland\Edinburgh\Edinburgh Castle</span>.
the output list would be <span style="font-family: monospace,monospace; font-size:1em;">Family\Mum; Family\Dad; Family\Gran; UK\Scotland\Edinburgh; UK\Scotland\Edinburgh\Edinburgh Castle</span>.
Using the <span style="font-family: monospace,monospace; font-size:1em;">&datatype=[list]</span> cast makes the expression split individual list items in a panes or categories view.</p>
Using the <span style="font-family: monospace,monospace; font-size:1em;">&datatype=[list]</span> cast makes the expression split individual list items in a panes or categories view.</p>
<p>[https://yabb.jriver.com/interact/index.php/topic,134242.msg929833.html#msg929833 This post by user zybex on the Interact forums] explains the different modes in a very clear, easy to understand way.</p>
|}
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>

=== <span id="ListContains">ListContains(&hellip;)</span> ===
: Checks for a value being in a list.

{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0"
|- id="ListContains" valign="top"
! scope="row" style="background: #ecedf3; color: #111; border-style: solid; border-width: 2px 1px 0 2px; border-right: 1px solid #bbb;" width="100" | Description
| style="background: #f9f9f9; color: #111; border-style: solid; border-width: 2px 2px 0 0" width="1200" | <span style="font-family: monospace,monospace; font-size:1em; color:#0f3f8d; font-size:110%"><b>listcontains(</b><i>list</i><b>, </b><i>value</i><b>, </b><i>flags</i><b>)</b></span>
The [[#ListContains|ListContains()]] function checks for a value in a list.

Argument <i>list</i> defines the list.
Argument <i>value</i> defines the value to search for.
Argument <i>flags</i> defines the search flags. 1 for case sensitive. 2 for full match only

|- valign="top"limi
! scope="row" style="background: #ecedf3; color: #111; border-style: solid; border-width: 0px 1px 2px 2px; border-top: 1px solid #bbb; border-right: 1px solid #bbb;" | Examples
|style="background: #f9f9f9; color: #111; border-style: solid; border-width: 0px 2px 2px 0; border-top: 1px solid #bbb;" | <span style="font-family: monospace,monospace; font-size:1em;">
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listcontains(a;b;c,a)</nowiki></b></span>
<p style="margin-left:20pt;">Returns 1.</p>
|}

<div style="text-align:right;">([[#top|Back to top)]]</div>
<div style="text-align:right;">([[#top|Back to top)]]</div>


Line 156: Line 185:
|}
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>
<div style="text-align:right;">([[#top|Back to top)]]</div>

=== <span id="ListEqual">ListEqual(&hellip;)</span> ===
: Checks for equality between two lists.

{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0"
|- id="ListEqual" valign="top"
! scope="row" style="background: #ecedf3; color: #111; border-style: solid; border-width: 2px 1px 0 2px; border-right: 1px solid #bbb;" width="100" | Description
| style="background: #f9f9f9; color: #111; border-style: solid; border-width: 2px 2px 0 0" width="1200" | <span style="font-family: monospace,monospace; font-size:1em; color:#0f3f8d; font-size:110%"><b>listequal(</b><i>list 1</i><b>, </b><i>list 2</i><b>)</b></span>
The [[#ListEqual|ListEqual()]] function checks for equality between two lists.

Argument <i>list 1</i> defines the first list.
Argument <i>list 2</i> defines the second list.

|- valign="top"limi
! scope="row" style="background: #ecedf3; color: #111; border-style: solid; border-width: 0px 1px 2px 2px; border-top: 1px solid #bbb; border-right: 1px solid #bbb;" | Examples
|style="background: #f9f9f9; color: #111; border-style: solid; border-width: 0px 2px 2px 0; border-top: 1px solid #bbb;" | <span style="font-family: monospace,monospace; font-size:1em;">
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listequal(a;b;c,a;b;c)</nowiki></b></span>
<p style="margin-left:20pt;">Returns 1.</p>
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>

=== <span id="ListFilter">ListFilter(&hellip;)</span> ===
: Filter any list, returning only values within a given range

{{function description box
| name=ListFilter
| arguments=List, Mode, Minimum Value, Maximum Value
| description=
The function filters any list, returning a list of values within a given range.
: ''"List"'' is the list to be searched and can be a literal given string, library field, or nested expression result. Only semi-colon delimited lists are accepted.
: ''"Mode"'' must be specified. Zero for a numeric range, or one for a string range. (0 or 1)
: ''"Minimum Value"'' is the start of the range to extract from the list.
: ''"Maximum Value"'' is the end of the range to extract from the list.
{{argument table
| name=Mode
| contents=
{{argument table row|0|Numeric}}
{{argument table row|1|String}}
}}

'''Notes:'''<br>
When using "Mode 1", the filter is case insensitive.<br>
When using letters, or strings of letters, in "Mode 0", results will return as zeros.<br>
All items in the source list, in the specified range, will be returned, regardless of the sorting of the source list. The output list will be ordered as found in the source list.<br>

| examples=
'''{{monospace|<nowiki>listfilter(1;2;3;4;5;a;b;c;d;e;6;7;8;9;10;A;B;C;D;E;1A;A1,0,4,7)</nowiki>}}'''
: Returns: 4;5;6;7

'''{{monospace|<nowiki>listfilter(1;2;3;4;5;a;b;c;d;e;6;7;8;9;10;A;B;C;D;E;1A;A1,1,a,c)</nowiki>}}'''
: Returns: a;b;c;A;B;C;A1

'''{{monospace|<nowiki>listfilter(1;2;3;4;5;a;b;c;d;e;6;7;8;9;10;A;B;C;D;E;1A;A1,0,A,C)</nowiki>}}'''
: Returns: 0;0;0;0;0;0;0;0;0;0;0
}}

=== <span id="ListFind">ListFind(&hellip;)</span> ===
: Returns list items containing specified text

{{function description box
| name=ListFind
| arguments=List, Search, Default, Return Mode, Match Mode
| description=
{{argument optional|Default|''Empty'' (Returns nothing)}}
{{argument optional|Return Mode|0}}
{{argument optional|Match Mode|0}}

: ''"List"'' is the list to be searched and can be a literal given string, library field, or nested expression result. Only semi-colon delimited lists are accepted.
: ''"Search"'' is the character or string you wish to locate within the ''"List"'' value. '''<i>The search performed is always case insensitive</i>'''.
: ''"Default"'' specifies what the output should be if ''Search'' is not found.
: ''"Mode"'' has two available values, defaulting to 0 if not specified... 0 returns the text of the found list item and 1 returns the zero-based index number of the item found in the given list. If using Mode 1, to return the list index value, and a return of -1 is desired for any "not found" results, leave the <i>Default</i> value empty.
{{argument table
| name=Return Mode
| contents=
{{argument table row|0|Return the text of the found list item}}
{{argument table row|1|Return the index of the found list item}}
}}
{{argument table
| name=Match Mode
| contents=
{{argument table row|0|Partial Matching}}
{{argument table row|1|Exact Matching}}
}}

As already mentioned, ''Search'' is always case insensitive, '''''even when using Match Mode "1".''''' It begins at the start of the string, and stops when it finds the first match. If ''Search'' appears later in the list, it is not reported.<br>
When using ''return mode'' 1, the zero based list index of the first item found is returned, and if not found, the <i>Default</i> value is returned if specified, or, if <i>Default</i> is left empty, -1 is returned. This is useful for combining with other zero-based functions such as [[#ListItem|ListItem()]], where the index may not be known, but can be returned using ListFind().

| examples=
'''{{monospace|<nowiki>ListFind(Rod;Jane;Freddy, Jane)</nowiki>}}'''
: Returns: Jane
In this example, ''Default'', ''Return Mode'' and ''Match Mode'' have not been specified, and so defaults to empty, zero and zero respectively.

'''{{monospace|<nowiki>ListFind(Rod;Jane;Freddy, Bungle)</nowiki>}}'''
: Returns: ''Nothing''
In this example, ''Default'', ''Return Mode'' and ''Match Mode'' have not been specified, and so defaults to empty, zero and zero respectively. "Bungle" is not found, so nothing at all is returned.

'''{{monospace|<nowiki>ListFind(Rod;Jane;Freddy, Bungle, Bungle is not in this list)</nowiki>}}'''
: Returns: Bungle is not in this list
In this example, ''Default'' has been specified, and will be returned if ''Search'' is not found. Neither ''Mode'' has been specified, and so both default to zero. "Bungle" is not found, so "Bungle is not in this list" is returned as the specified default.

'''{{monospace|<nowiki>ListFind(Rod;Jane;Freddy, Bungle, Bungle is not in this list,1)</nowiki>}}'''
: Returns: Bungle is not in this list
In this example, ''Default'' has been specified, so will be used even though ''Return Mode'' 1 has been specified to retrieve the item's list index #. As "Bungle" is not found, the specified default value, "Bungle is not in this list" is returned.

'''{{monospace|<nowiki>ListFind(Rod;Jane;Freddy, Bungle,,1)</nowiki>}}'''
: Returns: -1
In this example, ''Default'' has not been specified. ''Return Mode'' 1 has been specified to retrieve the item's list index #. As "Bungle" is not found, -1 is returned.

'''{{monospace|<nowiki>ListFind(Rod;Jane;Freddy, Freddy,,1)</nowiki>}}'''
: Returns: 2
In this example, ''Default'' has not been specified. ''Return Mode'' 1 has been specified to retrieve the item's list index #. The list index of 2 is returned as, starting from zero, "Freddy" is the third item in the list.
'''{{monospace|<nowiki>ListFind(Rod;Jane;Freddy, Fred,,0,1)</nowiki>}}'''
: Returns: Nothing.
In this example, ''Default'' has not been specified. ''Return Mode'' 0 has been specified to retrieve the item's text, and ''Match Mode'' 1 has been specified, indicating and exact match is required. Nothing is returned as Fred does not feature as an exact item in the list.
}}

=== <span id="ListFormat">ListFormat(&hellip;)</span> ===
: Outputs a given list in a reader friendly format

{{function description box
| name=ListFormat
| arguments=List, Mode
| description=

: ''"List"'' is the list to be worked on and can be a literal given string, library field, or nested expression result. Only semi-colon delimited lists are accepted.
: ''"Mode"'' has three available values, and has no default, so, <i>must</i> be specified.
{{argument table
| name=mode
| contents=
{{argument table row|0|Return the list as-is, adding a single space after each semicolon}}
{{argument table row|1|Replaces semicolons with a comma and space, adding an ampersand before the last item}}
{{argument table row|2|Replaces semicolons with a comma and space, adding an ampersand <i>without comma</i> before the last item}}


}}

| examples=
'''{{monospace|<nowiki>ListFormat(Rod;Jane;Freddy,0)</nowiki>}}'''
: Returns: Rod; Jane; Freddy

'''{{monospace|<nowiki>ListFormat(Rod;Jane;Freddy,1)</nowiki>}}'''
: Returns: Rod, Jane, & Freddy

'''{{monospace|<nowiki>ListFormat(Rod;Jane;Freddy,2)</nowiki>}}'''
: Returns: Rod, Jane & Freddy
}}

=== <span id="ListGrep">ListGrep(&hellip;)</span> ===
: Returns list items containing specified text

{{function description box
| name=ListGrep
| arguments=List, Filter, Mode
| description=
{{argument optional|mode|0}}
The [[#ListGrep|ListGrep()]] function searches a given ''list'' for all items containing specified text, returning results as a semi-colon delimted list. The source list can be given literally or as an existing list type library field, such as [Keywords]

{{argument table
| name=mode
| contents=
{{argument table row|0|Perform a case ''in''sensitive search}}
{{argument table row|1|Perform a case sensitive search}}

}}
| examples=
'''{{monospace|<nowiki>ListGrep(redneck;blue;Red roses, red)</nowiki>}}'''
: Returns: redneck; Red roses
In this example, ''Mode'' has not been specified, and so defaults to zero for a case insensitive search.

'''{{monospace|<nowiki>ListGrep(redneck;blue;Red roses, red,1)</nowiki>}}'''
: Returns: redneck
In this example, ''Mode'' 1 has been specified for a case-sensitive search, so, "Red roses" is ''not'' a match.

}}


=== <span id="ListItem">ListItem(&hellip;)</span> ===
=== <span id="ListItem">ListItem(&hellip;)</span> ===
Line 168: Line 371:
Nothing is returned with the <i>position</i> is outside the bounds of the <i>list</i>.
Nothing is returned with the <i>position</i> is outside the bounds of the <i>list</i>.


Argument <i>delimiter</i> is optional (defaults to SEMICOLON).
Argument <i>delimiter</i> is optional (defaults to SEMICOLON).<br>
Argument <i>position</i> accepts negative numbers, indicating that the search be performed from the end of the list, not the start, with -1 returning the last list item..


|- valign="top"
|- valign="top"
Line 179: Line 383:
<div style="text-align:right;">([[#top|Back to top)]]</div>
<div style="text-align:right;">([[#top|Back to top)]]</div>


=== <span id="ListSort">ListSort(&hellip;)</span> ===
=== <span id="ListLimit">ListLimit(&hellip;)</span> ===
: Sort a list of values.
: Returns a specified number of list items


{{function description box
{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0"
| name=ListLimit
|- id="ListSort" valign="top"
| arguments=List, Limit, Start, Delimiter
! scope="row" style="background: #ecedf3; color: #111; border-style: solid; border-width: 2px 1px 0 2px; border-right: 1px solid #bbb;" width="100" | Description
| description=
| style="background: #f9f9f9; color: #111; border-style: solid; border-width: 2px 2px 0 0" width="1200" | <span style="font-family: monospace,monospace; font-size:1em; color:#0f3f8d; font-size:110%"><b>listsort(</b><i>list</i><b>, </b><i>mode</i><b>, </b><i>delimiter</i><b>)</b></span>
{{argument optional|Start|0}}
The [[#ListSort|ListSort()]] function sorts a <i>list</i> in the order according to <i>mode</i>, using the specified <i>delimiter</i>.
{{argument optional|Delimiter|;}}


: ''"List"'' is the source list to be capped.
Available <i>mode</i> values:
: ''"Limit"'' is the number of items to return from {{monospace|''List''}}. Negative numbers can be used here to return items from the end of the {{monospace|''List''}}.
: ''"Start"'' is optional and defaults to zero (the beginning of the list).
: ''"Delimiter"'' is optional and defaults to a semi-colon if not specified.


<b><u>Notes:</u></b>
<div style="margin-left: 20pt;"><table style="border-spacing:0px; border-collapse:collapse; background: #f9f9f9">
: If a {{monospace|Start}} value that is outside the bounds of the source list is specified, for example, start at item 10 when the list only contains nine items, the function returns a null (empty) result.
<tr><td style="text-align:left; padding-right:20pt"><b>0</b></td><td>Ascending sort</td></tr>
: {{monospace|Start}} is a zero-based index, so a start value of "1" will begin from the second list item.
<tr><td style="text-align:left; padding-right:20pt"><b>1</b></td><td>Descending sort</td></tr>
</table></div>


| examples=
Argument <i>mode</i> is optional (defaults to 0).
'''{{monospace|<nowiki>ListLimit([Actors],5)</nowiki>}}'''
: Returns a semi-colon delimited list of the first five actors from the [Actors] list.


'''{{monospace|<nowiki>ListLimit([Actors],-5)</nowiki>}}'''
Argument <i>delimiter</i> is optional (defaults to SEMICOLON).
: Returns a semi-colon delimited list of the last five actors from the [Actors] list.


'''{{monospace|<nowiki>ListLimit([Actors],5,3)</nowiki>}}'''
|- valign="top"
: Returns a semi-colon delimited list of five actors from the [Actors] list, starting from the ''fourth'' item in that [Actors] list.
! scope="row" style="background: #ecedf3; color: #111; border-style: solid; border-width: 0px 1px 2px 2px; border-top: 1px solid #bbb; border-right: 1px solid #bbb;" | Examples
}}
|style="background: #f9f9f9; color: #111; border-style: solid; border-width: 0px 2px 2px 0; border-top: 1px solid #bbb;" | <span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listsort(c;a;b)</nowiki></b></span>
<p style="margin-left:20pt;">Returns <span style="font-family: monospace,monospace; font-size:1em;">a;b;c</span>, using the default ascending <i>mode</i> and (<span style="font-family: monospace,monospace; font-size:1em;">:</span>) <i>delimiter</i>.</p>
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listsort(Joe Baxter/, Sally Henson/, Sue Smith, 1, /,)</nowiki></b></span>
<p style="margin-left:20pt;">Returns <span style="font-family: monospace,monospace; font-size:1em;">Sue Smith,Sally Henson,Joe Baxter</span>.
Note the requirement to escape the <span style="font-family: monospace,monospace; font-size:1em;">,</span> characters within the <i>list</i> string and in the specified <i>delimiter</i> itself.</p>
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listsort([artist];[composer])</nowiki></b></span>
<p style="margin-left:20pt;">Sorts the combined artist and composer lists in ascending order.
Note the simple manual construction of a single List by combining the two List type fields, and forcing a <span style="font-family: monospace,monospace; font-size:1em;">;</span> between the two.</p>
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>


=== <span id="ListLimit">ListLimit(&hellip;)</span> ===
=== <span id="ListMath">ListMath(&hellip;)</span> ===
: Caps the number of items in a list.
: Returns a specified number of list items


{{function description box
{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0"
| name=ListMath
|- id="ListLimit" valign="top"
| arguments=List, Mode
! scope="row" style="background: #ecedf3; color: #111; border-style: solid; border-width: 2px 1px 0 2px; border-right: 1px solid #bbb;" width="100" | Description
| description=
| style="background: #f9f9f9; color: #111; border-style: solid; border-width: 2px 2px 0 0" width="1200" | <span style="font-family: monospace,monospace; font-size:1em; color:#0f3f8d; font-size:110%"><b>listlimit(</b><i>list</i><b>, </b><i>limit</i><b>, </b><i>start</i><b>)</b></span>
{{argument table
The [[#ListLimit|ListLimit()]] function caps the number of items in a <i>list</i>.ca
| contents=
{{argument table row|0|Math function "Min"}}
{{argument table row|1|Math function "Max"}}
{{argument table row|2|Math function "Sum"}}
{{argument table row|3|Math function "Average"}}
}}


<b><u>Notes:</u></b>
Argument <i>limit</i> defines the number of items to cap at. You can use negative numbers to return items from the end of a list.
: {{monospace|''List''}} can be a mix of numeric and textual items. Any textual list items are evaluated as zero.
Argument <i>start</i> optionally defines the start item.


| examples=
|- valign="top"
'''{{monospace|<nowiki>ListMath(1;two;2;three;3;4;5,0)</nowiki>}}'''
! scope="row" style="background: #ecedf3; color: #111; border-style: solid; border-width: 0px 1px 2px 2px; border-top: 1px solid #bbb; border-right: 1px solid #bbb;" | Examples
: Returns zero as the words "two" and "three" evaluate to zero.
|style="background: #f9f9f9; color: #111; border-style: solid; border-width: 0px 2px 2px 0; border-top: 1px solid #bbb;" | <span style="font-family: monospace,monospace; font-size:1em;">
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listlimit(a;b;c,1,0)</nowiki></b></span>
<p style="margin-left:20pt;">Returns a.</p>
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listlimit(a;b;c,-1,0)</nowiki></b></span>
<p style="margin-left:20pt;">Returns c.</p>
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>


'''{{monospace|<nowiki>ListMath(1;two;2;three;3;4;5,1)</nowiki>}}'''
=== <span id="ListEqual">ListEqual(&hellip;)</span> ===
: Returns 5.
: Checks for equality between two lists.


'''{{monospace|<nowiki>ListMath(1;two;2;three;3;4;5,2)</nowiki>}}'''
{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0"
: Returns 15.
|- id="ListEqual" valign="top"
! scope="row" style="background: #ecedf3; color: #111; border-style: solid; border-width: 2px 1px 0 2px; border-right: 1px solid #bbb;" width="100" | Description
| style="background: #f9f9f9; color: #111; border-style: solid; border-width: 2px 2px 0 0" width="1200" | <span style="font-family: monospace,monospace; font-size:1em; color:#0f3f8d; font-size:110%"><b>listequal(</b><i>list 1</i><b>, </b><i>list 2</i><b>)</b></span>
The [[#ListEqual|ListEqual()]] function checks for equality between two lists.


'''{{monospace|<nowiki>ListMath(1;two;2;three;3;4;5,3)</nowiki>}}'''
Argument <i>list 1</i> defines the first list.
: Returns 2.142857 (15/7)
Argument <i>list 2</i> defines the second list.
}}


=== <span id="ListMix">ListMix(&hellip;)</span> ===
|- valign="top"limi
: Combine corresponding values from multiple lists into a new list, using a template to process each item.
! scope="row" style="background: #ecedf3; color: #111; border-style: solid; border-width: 0px 1px 2px 2px; border-top: 1px solid #bbb; border-right: 1px solid #bbb;" | Examples
|style="background: #f9f9f9; color: #111; border-style: solid; border-width: 0px 2px 2px 0; border-top: 1px solid #bbb;" | <span style="font-family: monospace,monospace; font-size:1em;">
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listequal(a;b;c,a;b;c)</nowiki></b></span>
<p style="margin-left:20pt;">Returns 1.</p>
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>


{{function description box
=== <span id="ListContains">ListContains(&hellip;)</span> ===
| name=ListMix
: Checks for a value being in a list.
| arguments=template, mode, list1, [list2, ... listN]
| description=
{{argument optional|mode|0}}
The [[#ListMix|ListMix()]] function processes the elements of one or more lists, returning a new list where each element is similar to the provided template modified with the elements of the list argument(s).
The number of list arguments to be mixed is variable, but at least one must be provided. The lists can have different lengths, with mode controlling the length of the returned list.
The first element of the returned list is generated by applying the first element of each provided list to the template; the second element is generated using the second element(s) of the list(s), and so on until all elements are processed, according to mode.


The <i>'''template'''</i> is a text string with placeholders like [L1], [L2], etc, indicating where the elements of the provided lists should be inserted. [L1] refers to elements of list1, [L2] refers to list2, and so on. The special placeholder [N] refers to the item number within the resulting list.
{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0"
|- id="ListContains" valign="top"
! scope="row" style="background: #ecedf3; color: #111; border-style: solid; border-width: 2px 1px 0 2px; border-right: 1px solid #bbb;" width="100" | Description
| style="background: #f9f9f9; color: #111; border-style: solid; border-width: 2px 2px 0 0" width="1200" | <span style="font-family: monospace,monospace; font-size:1em; color:#0f3f8d; font-size:110%"><b>listcontains(</b><i>list</i><b>, </b><i>value</i><b>, </b><i>flags</i><b>)</b></span>
The [[#ListContains|ListContains()]] function checks for a value in a list.


A <i>'''template'''</i> is also itself an Expression, so it can contain other functions/expressions. A template can be escaped using the escape sequence /#template#/. This is usually not required but may be useful to enter templates containing functions, commas, or other special symbols.
Argument <i>list</i> defines the list.
Argument <i>value</i> defines the value to search for.
Argument <i>flags</i> defines the search flags. 1 for case sensitive. 2 for full match only


The default semi-colon list delimiter is used for both input and output lists.
|- valign="top"limi
! scope="row" style="background: #ecedf3; color: #111; border-style: solid; border-width: 0px 1px 2px 2px; border-top: 1px solid #bbb; border-right: 1px solid #bbb;" | Examples
|style="background: #f9f9f9; color: #111; border-style: solid; border-width: 0px 2px 2px 0; border-top: 1px solid #bbb;" | <span style="font-family: monospace,monospace; font-size:1em;">
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listcontains(a;b;c,a)</nowiki></b></span>
<p style="margin-left:20pt;">Returns 1.</p>
|}


{{argument table
<div style="text-align:right;">([[#top|Back to top)]]</div>
| name=mode
| contents=
{{argument table row|0|Return as many elements as the '''longest''' provided list}}
{{argument table row|1|Return as many elements as the '''shortest''' provided list}}
{{argument table row|2|Return as many elements as the '''first''' provided list}}
{{argument table row|4|Do not evaluate the inner portion as another expression}}
{{argument table row|8|Do no unescape after everything}}

}}
| examples=
'''{{monospace|<nowiki>ListMix(Actor #[N] is [L1],, a;b;c)</nowiki>}}'''
: Returns Actor #1 is a; Actor #2 is b; Actor #3 is c
This example uses mode 0 and demonstrates the usage of [N] and [L1] on a single list.

'''{{monospace|<nowiki>ListMix([L1][L2]=[L3], 0, a;b;c;d, 1;2;3;4;5, blue;red;green)</nowiki>}}'''
: Returns a1=blue; b2=red; c3=green; d4=; 5=
Mode 0 returns 5 elements which is the length of the longest list. Note that on the last two the missing values on the template are also missing on the output.

'''{{monospace|<nowiki>ListMix([L1][L2]=[L3], 1, a;b;c;d, 1;2;3;4;5, blue;red;green)</nowiki>}}'''
: Returns a1=blue; b2=red; c3=green
: Mode 1 returns only 3 elements, the length of the shortest list.

'''{{monospace|<nowiki>ListMix([L1][L2]=[L3], 2, a;b;c;d, 1;2;3;4;5, blue;red;green)</nowiki>}}'''
: Returns : a1=blue; b2=red; c3=green; d4=
: Mode 2 returns only 4 elements, the length of the first list.

'''{{monospace|<nowiki>ListMix(FixCase([L1],3)=Math([L2]*[L3]),, aa;bb;cc, 10;20;30, 5;4;3)</nowiki>}}'''
: Returns : AA=50; BB=80; CC=90
: This example uses two different functions on the template to further transform each element of the lists before inserting it into the output.


'''{{monospace|<nowiki>ListMix(<img src=tooltip:actors\[L1]>, 1, [Actors], 1;2;3;4;5)</nowiki>}}'''
: Returns (example): <img src=tooltip:actors\Daisy Ridley>;<img src=tooltip:actors\Adam Driver>;<img src=tooltip:actors\John Boyega>;<img src=tooltip:actors\Oscar Isaac>;<img src=tooltip:actors\Mark Hamill>
: This example transforms the [Actors] field into a list of <img> tags ready to load the actor thumbnails into the Theather View or Movie Tooltip. It uses mode 1 (shortest list) with a dummy [L2] list of 5 elements to make sure the resulting list is at most 5 items long. An alternative way to accomplish the same would be to use ListLimit([Actors],5) as [L1].

}}

=== <span id="ListRemove">ListRemove(&hellip;)</span> ===
: Removes a string from a list.

{{function description box
| name=ListRemove
| arguments=List, String, List Item, Mode
| description=
{{argument optional|mode|0}}
The [[#ListRemove|ListRemove()]] function removes a given <i>string</i> from a <i>list</i>.

{{argument table
| name=mode
| contents=
{{argument table row|0|Searches for a given string, removing it if found}}
{{argument table row|1|Zero-based index mode, will remove the specified list item}}
{{argument table row|2|Performs a substring search and remove}}
}}

'''Notes'''
: The <i>List Item</i> argument is only required when using <i>Mode 1</i>, remembering that the list items are numbered starting from zero.
: When using mode zero, the search performed is ''case insensitive''
: When using mode zero, the string to be removed must match the whole list item, otherwise, nothing is removed.
: When using mode 1, the ''List Item'' zero-based number is specified in place of ''String''.
: When using mode 2, wherever the specified substring is found, that entire list entry is removed. See 3rd example below.

| examples=
'''{{monospace|<nowiki>listremove(This;Is;a;List,is)</nowiki>}}'''
: Returns "This;a;List"
This example defaults to mode 0. Note that "is" in ''"List"'' and and ''"This"'' are not removed, and the search is case insensitive.

'''{{monospace|<nowiki>listremove(a;b;c;d;e;f;g,5,1)</nowiki>}}'''
: Returns a;b;c;d;e;g
Mode 1 has been specified, which is a zero-based index mode, so "f" has been removed from the list as it is the fifth list item.

'''{{monospace|<nowiki>listremove(This;Is;a;List,is,2)</nowiki>}}'''
: Returns "a"
This example uses mode 2 which performs a substring search for "is", removing This, Is and List, leaving just "a". The search is case insensitive.

}}


=== <span id="ListShuffle">ListShuffle(&hellip;)</span> ===
=== <span id="ListShuffle">ListShuffle(&hellip;)</span> ===
Line 282: Line 547:
|- id="ListShuffle" valign="top"
|- id="ListShuffle" valign="top"
! scope="row" style="background: #ecedf3; color: #111; border-style: solid; border-width: 2px 1px 0 2px; border-right: 1px solid #bbb;" width="100" | Description
! scope="row" style="background: #ecedf3; color: #111; border-style: solid; border-width: 2px 1px 0 2px; border-right: 1px solid #bbb;" width="100" | Description
| style="background: #f9f9f9; color: #111; border-style: solid; border-width: 2px 2px 0 0" width="1200" | <span style="font-family: monospace,monospace; font-size:1em; color:#0f3f8d; font-size:110%"><b>listshuffle(</b><i>list</i><b>, </b><i>mode</i><b>, </b><i>delimiter</i><b>)</b></span>
| style="background: #f9f9f9; color: #111; border-style: solid; border-width: 2px 2px 0 0" width="1200" | <span style="font-family: monospace,monospace; font-size:1em; color:#0f3f8d; font-size:110%"><b>listshuffle(</b><i>list</i><b>)</b></span>
The [[#ListShuffle|ListShuffle()]] function shuffles the given <i>list</i>.
The [[#ListShuffle|ListShuffle()]] function shuffles the given <i>list</i>.

|- valign="top"
! scope="row" style="background: #ecedf3; color: #111; border-style: solid; border-width: 0px 1px 2px 2px; border-top: 1px solid #bbb; border-right: 1px solid #bbb;" | Examples
|style="background: #f9f9f9; color: #111; border-style: solid; border-width: 0px 2px 2px 0; border-top: 1px solid #bbb;" | <span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listshuffle(c;b;a)</nowiki></b></span>
<p style="margin-left:20pt;">Shuffles the <i>list</i>, returning some arrangement of the letters.</p>
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>

=== <span id="ListSort">ListSort(&hellip;)</span> ===
: Sort a list of values.

{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0"
|- id="ListSort" valign="top"
! scope="row" style="background: #ecedf3; color: #111; border-style: solid; border-width: 2px 1px 0 2px; border-right: 1px solid #bbb;" width="100" | Description
| style="background: #f9f9f9; color: #111; border-style: solid; border-width: 2px 2px 0 0" width="1200" | <span style="font-family: monospace,monospace; font-size:1em; color:#0f3f8d; font-size:110%"><b>listsort(</b><i>list</i><b>, </b><i>mode</i><b>, </b><i>delimiter</i><b>)</b></span>
The [[#ListSort|ListSort()]] function sorts a <i>list</i> in the order according to <i>mode</i>, using the specified <i>delimiter</i>.

Available <i>mode</i> values:


<div style="margin-left: 20pt;"><table style="border-spacing:0px; border-collapse:collapse; background: #f9f9f9">
<div style="margin-left: 20pt;"><table style="border-spacing:0px; border-collapse:collapse; background: #f9f9f9">
<tr><td style="text-align:left; padding-right:20pt"><b>1</b></td><td>Remove duplicates</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>0</b></td><td>Ascending sort</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>2</b></td><td>Reverse the order of items</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>1</b></td><td>Descending sort</td></tr>
</table></div>
</table></div>

Argument <i>mode</i> is optional (defaults to 0).


Argument <i>delimiter</i> is optional (defaults to SEMICOLON).
Argument <i>delimiter</i> is optional (defaults to SEMICOLON).
Line 294: Line 579:
|- valign="top"
|- valign="top"
! scope="row" style="background: #ecedf3; color: #111; border-style: solid; border-width: 0px 1px 2px 2px; border-top: 1px solid #bbb; border-right: 1px solid #bbb;" | Examples
! scope="row" style="background: #ecedf3; color: #111; border-style: solid; border-width: 0px 1px 2px 2px; border-top: 1px solid #bbb; border-right: 1px solid #bbb;" | Examples
|style="background: #f9f9f9; color: #111; border-style: solid; border-width: 0px 2px 2px 0; border-top: 1px solid #bbb;" | <span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listshuffle(c;b;a)</nowiki></b></span>
|style="background: #f9f9f9; color: #111; border-style: solid; border-width: 0px 2px 2px 0; border-top: 1px solid #bbb;" | <span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listsort(c;a;b)</nowiki></b></span>
<p style="margin-left:20pt;">Removes duplicates from the <i>list</i>, returning <span style="font-family: monospace,monospace; font-size:1em;">c;b;a</span>.</p>
<p style="margin-left:20pt;">Returns <span style="font-family: monospace,monospace; font-size:1em;">a;b;c</span>, using the default ascending <i>mode</i> and (<span style="font-family: monospace,monospace; font-size:1em;">:</span>) <i>delimiter</i>.</p>
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listclean(d;c;b;a, 2) </nowiki></b></span>
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listsort(Joe Baxter/, Sally Henson/, Sue Smith, 1, /,)</nowiki></b></span>
<p style="margin-left:20pt;">Reverses the <i>list</i> items, returning <span style="font-family: monospace,monospace; font-size:1em;">a;b;c;d</span>.</p>
<p style="margin-left:20pt;">Returns <span style="font-family: monospace,monospace; font-size:1em;">Sue Smith,Sally Henson,Joe Baxter</span>.
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listclean(\a\x\x\x\z, 1, \) </nowiki></b></span>
Note the requirement to escape the <span style="font-family: monospace,monospace; font-size:1em;">,</span> characters within the <i>list</i> string and in the specified <i>delimiter</i> itself.</p>
<p style="margin-left:20pt;">Removes duplicates from a backslash-separated <i>list</i>, returning <span style="font-family: monospace,monospace; font-size:1em;">\a\x\z</span>.</p>
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>listsort([artist];[composer])</nowiki></b></span>
<p style="margin-left:20pt;">Sorts the combined artist and composer lists in ascending order.
Note the simple manual construction of a single List by combining the two List type fields, and forcing a <span style="font-family: monospace,monospace; font-size:1em;">;</span> between the two.</p>
|}
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>
<div style="text-align:right;">([[#top|Back to top)]]</div>

Latest revision as of 04:53, 11 February 2023

Media Center supports several different types of fields, one of them being the List type. A List type is a library field of type List, or an expression coerced into a list type.

The functions in this section provide the ability to manipulate lists and list items. A list is a sequence of strings, each separated from one another by an arbitrary delimiter. The default delimiter is a semicolon. Media Center does not make a strict distinction between a string and a list of strings. In fact, a list is just a string, and it is safe to think of a string as a list with zero or more arbitrary delimiter sequences. For example, the string "2013-08-17" can be thought of as a dash-delimited list with the three items "2013", "08" and "17".

This weak typing is very useful since a list, for example, "John; Sally" that contains the two items "John" and "Sally" can be manipulated not only using the list functions in this section, but because it is just a string, it can also be manipulated with string functions. For example, taking the same list above and combining it with the string "; Joe" adds a new item to the list "John; Sally; Joe", and removing the first 6 characters with RemoveLeft() would produce a now shortened string/list "Sally; Joe". The list manipulation functions make this job easier, especially when using the default semicolon delimiter. Furthermore, since any character or sequence of characters can be considered as a list delimiter, any string can be treated as a list, and the functions in this section can be used on any string as needed.

In some areas such as a panes column, or a category view, Media Center gives special treatment to List types. For example, using semicolon as the delimiter, a List will be automatically split apart into its individual items.

ListBuild(…)

Constructs a list from a series of items.
Description listbuild(mode, delimiter, item1, item2, )

The ListBuild() function constructs a list from item1, item2, ... using a supplied delimiter to separate the individual items in the resulting list. The construction mode affects how empty items are handled - they can be included or excluded. The mode typically used exclude empty items, so that lists do not contain empty slots. However, there are occasions when retaining empty slots is useful, such as when using a list to act like an array where data is stored in particular slots so that the ListItem() function may later retrieve values at a given index. It can also be useful when calculating several expressions and combining the results into a single list for presentation; by including all items, items can be made to line-up for visual inspection in a column.

Available mode values:

0Include empty values
1Exclude empty values

The delimiter argument specifies the character or character sequence to be inserted in between items in the list. An unspecified delimiter will result in a delimiter-less concatenation of the supplied arguments item1, item2, etc.

Argument delimiter is optional (defaults to EMPTY).

Examples listbuild(1, ;, Bennie, June)

Returns a standard semicolon-separated list containing two items Bennie; June.

listbuild(1, \, [album artist (auto)], [album])

Builds a backslash-separated list combining the two fields album artist (auto) and album. This is useful for building panes column or categories hierarchies in a view.

(Back to top)

ListClean(…)

Various list operations.
Description listclean(list, mode, delimiter)

The ListClean() function performs one of the operations specified by mode on the given list. The specified delimiter separates list items.

Available mode values:

1Remove duplicates
2Reverse the order of items
3Remove empty items
4Trim (Removes any trailing delimiter)

Argument delimiter is optional (defaults to SEMICOLON).

Examples listclean(c;b;c;a, 1)

Removes duplicates from the list, returning c;b;a.

listclean(d;c;b;a, 2)

Reverses the list items, returning a;b;c;d.

listclean(\a\x\x\x\z, 1, \)

Removes duplicates from a backslash-separated list, returning \a\x\z.

(Back to top)

ListCombine(…)

Combines two delimited lists into a single delimited list.
Description listcombine(list1, list2, input delimiter, output delimiter, mode)

The ListCombine() function returns a single list after performing the operation specified by mode on the two lists list1 and list2. An input delimiter and an output delimiter may be specified. The input delimiter is effective for both list1 and list2, and the output delimiter will be used in the returned list, replacing the input delimiter from both list1 and list2.

Available mode values:

0Combine lists removing duplicates (order is preserved).
1Output only items contained in both lists (order is preserved).
2Output only items NOT contained in both lists (order is preserved).
3Output the first list without any values present in the second list (order is preserved).

Argument input delimiter is optional (defaults to SEMICOLON).

Argument output delimiter is optional (defaults to SEMICOLON).

Argument mode is optional (defaults to 0).

Examples listcombine(a;b;e, a;b;c;d)

Returns a;b;e;c;d. This example uses the default mode 0 to combine list1 with list2, preserving the order of items. The default ; input delimiter and output delimiter is used.

listcombine(a;b;e, a;b;c;d, ;, ;, 1)

Returns a;b. The input delimiter and output delimiter are both specified as ;, and mode 1 is used to produce a list of only items that exist in both list1 and list2.

listcombine(a-c, c-f, -, ..., 0)

Returns a...c...f. The input delimiter is -, while the output delimiter is ..., and mode 0 combines both lists.

listcombine(a#@#c, c#@#f, #@#, ., 0)

Returns a.c.f. This example demonstrates how to combine two lists with duplicates removed while replacing a multi-character input delimiter #@# with a single-character output delimiter ..

listcombine([people], [places])&datatype=[list]

The result here would be a single, semicolon delimited list containing all the list items from the [people] and [places] fields. For example, if [people] contains Family\Mum; Family\Dad; Family\Gran, and [places] contains UK\Scotland\Edinburgh; UK\Scotland\Edinburgh\Edinburgh Castle, the output list would be Family\Mum; Family\Dad; Family\Gran; UK\Scotland\Edinburgh; UK\Scotland\Edinburgh\Edinburgh Castle. Using the &datatype=[list] cast makes the expression split individual list items in a panes or categories view.

This post by user zybex on the Interact forums explains the different modes in a very clear, easy to understand way.

(Back to top)

ListContains(…)

Checks for a value being in a list.
Description listcontains(list, value, flags)

The ListContains() function checks for a value in a list.

Argument list defines the list. Argument value defines the value to search for. Argument flags defines the search flags. 1 for case sensitive. 2 for full match only

Examples

listcontains(a;b;c,a)

Returns 1.

(Back to top)

ListCount(…)

Returns the number of items in a list.
Description listcount(list, delimiter)

The ListCount() function returns the number of items that exist in a list delimited by delimiter.

Argument delimiter is optional (defaults to SEMICOLON).

Examples listcount([keywords])

Returns the number of keywords for the file.

listcount([filename (path)], \)

Returns the number of the directories in a Windows drive-based file path. The example demonstrates that non-List type fields can be used with the functions in this section. While the delimiter specified here is \, an escaped forward slash // could be used when applicable.

(Back to top)

ListEqual(…)

Checks for equality between two lists.
Description listequal(list 1, list 2)

The ListEqual() function checks for equality between two lists.

Argument list 1 defines the first list. Argument list 2 defines the second list.

Examples

listequal(a;b;c,a;b;c)

Returns 1.

(Back to top)

ListFilter(…)

Filter any list, returning only values within a given range
Description ListFilter(List, Mode, Minimum Value, Maximum Value)

The function filters any list, returning a list of values within a given range.

"List" is the list to be searched and can be a literal given string, library field, or nested expression result. Only semi-colon delimited lists are accepted.
"Mode" must be specified. Zero for a numeric range, or one for a string range. (0 or 1)
"Minimum Value" is the start of the range to extract from the list.
"Maximum Value" is the end of the range to extract from the list.

Available Mode values:

0Numeric
1String

Notes:
When using "Mode 1", the filter is case insensitive.
When using letters, or strings of letters, in "Mode 0", results will return as zeros.
All items in the source list, in the specified range, will be returned, regardless of the sorting of the source list. The output list will be ordered as found in the source list.

Examples listfilter(1;2;3;4;5;a;b;c;d;e;6;7;8;9;10;A;B;C;D;E;1A;A1,0,4,7)
Returns: 4;5;6;7

listfilter(1;2;3;4;5;a;b;c;d;e;6;7;8;9;10;A;B;C;D;E;1A;A1,1,a,c)

Returns: a;b;c;A;B;C;A1

listfilter(1;2;3;4;5;a;b;c;d;e;6;7;8;9;10;A;B;C;D;E;1A;A1,0,A,C)

Returns: 0;0;0;0;0;0;0;0;0;0;0
(Back to top)   (Function index)

ListFind(…)

Returns list items containing specified text
Description ListFind(List, Search, Default, Return Mode, Match Mode)
  • Argument Default is optional (defaults to Empty (Returns nothing)).
  • Argument Return Mode is optional (defaults to 0).
  • Argument Match Mode is optional (defaults to 0).
"List" is the list to be searched and can be a literal given string, library field, or nested expression result. Only semi-colon delimited lists are accepted.
"Search" is the character or string you wish to locate within the "List" value. The search performed is always case insensitive.
"Default" specifies what the output should be if Search is not found.
"Mode" has two available values, defaulting to 0 if not specified... 0 returns the text of the found list item and 1 returns the zero-based index number of the item found in the given list. If using Mode 1, to return the list index value, and a return of -1 is desired for any "not found" results, leave the Default value empty.

Available Return Mode values:

0Return the text of the found list item
1Return the index of the found list item

Available Match Mode values:

0Partial Matching
1Exact Matching

As already mentioned, Search is always case insensitive, even when using Match Mode "1". It begins at the start of the string, and stops when it finds the first match. If Search appears later in the list, it is not reported.
When using return mode 1, the zero based list index of the first item found is returned, and if not found, the Default value is returned if specified, or, if Default is left empty, -1 is returned. This is useful for combining with other zero-based functions such as ListItem(), where the index may not be known, but can be returned using ListFind().

Examples ListFind(Rod;Jane;Freddy, Jane)
Returns: Jane

In this example, Default, Return Mode and Match Mode have not been specified, and so defaults to empty, zero and zero respectively.

ListFind(Rod;Jane;Freddy, Bungle)

Returns: Nothing

In this example, Default, Return Mode and Match Mode have not been specified, and so defaults to empty, zero and zero respectively. "Bungle" is not found, so nothing at all is returned.

ListFind(Rod;Jane;Freddy, Bungle, Bungle is not in this list)

Returns: Bungle is not in this list

In this example, Default has been specified, and will be returned if Search is not found. Neither Mode has been specified, and so both default to zero. "Bungle" is not found, so "Bungle is not in this list" is returned as the specified default.

ListFind(Rod;Jane;Freddy, Bungle, Bungle is not in this list,1)

Returns: Bungle is not in this list

In this example, Default has been specified, so will be used even though Return Mode 1 has been specified to retrieve the item's list index #. As "Bungle" is not found, the specified default value, "Bungle is not in this list" is returned.

ListFind(Rod;Jane;Freddy, Bungle,,1)

Returns: -1

In this example, Default has not been specified. Return Mode 1 has been specified to retrieve the item's list index #. As "Bungle" is not found, -1 is returned.

ListFind(Rod;Jane;Freddy, Freddy,,1)

Returns: 2

In this example, Default has not been specified. Return Mode 1 has been specified to retrieve the item's list index #. The list index of 2 is returned as, starting from zero, "Freddy" is the third item in the list. ListFind(Rod;Jane;Freddy, Fred,,0,1)

Returns: Nothing.

In this example, Default has not been specified. Return Mode 0 has been specified to retrieve the item's text, and Match Mode 1 has been specified, indicating and exact match is required. Nothing is returned as Fred does not feature as an exact item in the list.

(Back to top)   (Function index)

ListFormat(…)

Outputs a given list in a reader friendly format
Description ListFormat(List, Mode)
"List" is the list to be worked on and can be a literal given string, library field, or nested expression result. Only semi-colon delimited lists are accepted.
"Mode" has three available values, and has no default, so, must be specified.

Available mode values:

0Return the list as-is, adding a single space after each semicolon
1Replaces semicolons with a comma and space, adding an ampersand before the last item
2Replaces semicolons with a comma and space, adding an ampersand without comma before the last item
Examples ListFormat(Rod;Jane;Freddy,0)
Returns: Rod; Jane; Freddy

ListFormat(Rod;Jane;Freddy,1)

Returns: Rod, Jane, & Freddy

ListFormat(Rod;Jane;Freddy,2)

Returns: Rod, Jane & Freddy
(Back to top)   (Function index)

ListGrep(…)

Returns list items containing specified text
Description ListGrep(List, Filter, Mode)
  • Argument mode is optional (defaults to 0).

The ListGrep() function searches a given list for all items containing specified text, returning results as a semi-colon delimted list. The source list can be given literally or as an existing list type library field, such as [Keywords]

Available mode values:

0Perform a case insensitive search
1Perform a case sensitive search
Examples ListGrep(redneck;blue;Red roses, red)
Returns: redneck; Red roses

In this example, Mode has not been specified, and so defaults to zero for a case insensitive search.

ListGrep(redneck;blue;Red roses, red,1)

Returns: redneck

In this example, Mode 1 has been specified for a case-sensitive search, so, "Red roses" is not a match.

(Back to top)   (Function index)

ListItem(…)

Returns an item from a location in a list.
Description listitem(list, position, delimiter)

The ListItem() function returns the item from the specified position in the list. Items in a list are zero-based, so the first item in the list is located at position 0. Nothing is returned with the position is outside the bounds of the list.

Argument delimiter is optional (defaults to SEMICOLON).
Argument position accepts negative numbers, indicating that the search be performed from the end of the list, not the start, with -1 returning the last list item..

Examples listitem(a;b;c, 1)

Returns b, since position 1 is the second item in the list a;b;c.

listitem(1:04:47, 2, :)

Using the delimiter :, returns item at position 2, which is the seconds value 47 from the time 1:04:47.

(Back to top)

ListLimit(…)

Returns a specified number of list items
Description ListLimit(List, Limit, Start, Delimiter)
  • Argument Start is optional (defaults to 0).
  • Argument Delimiter is optional (defaults to ;).
"List" is the source list to be capped.
"Limit" is the number of items to return from List. Negative numbers can be used here to return items from the end of the List.
"Start" is optional and defaults to zero (the beginning of the list).
"Delimiter" is optional and defaults to a semi-colon if not specified.

Notes:

If a Start value that is outside the bounds of the source list is specified, for example, start at item 10 when the list only contains nine items, the function returns a null (empty) result.
Start is a zero-based index, so a start value of "1" will begin from the second list item.
Examples ListLimit([Actors],5)
Returns a semi-colon delimited list of the first five actors from the [Actors] list.

ListLimit([Actors],-5)

Returns a semi-colon delimited list of the last five actors from the [Actors] list.

ListLimit([Actors],5,3)

Returns a semi-colon delimited list of five actors from the [Actors] list, starting from the fourth item in that [Actors] list.
(Back to top)   (Function index)

ListMath(…)

Returns a specified number of list items
Description ListMath(List, Mode)

Available mode values:

0Math function "Min"
1Math function "Max"
2Math function "Sum"
3Math function "Average"

Notes:

List can be a mix of numeric and textual items. Any textual list items are evaluated as zero.
Examples ListMath(1;two;2;three;3;4;5,0)
Returns zero as the words "two" and "three" evaluate to zero.

ListMath(1;two;2;three;3;4;5,1)

Returns 5.

ListMath(1;two;2;three;3;4;5,2)

Returns 15.

ListMath(1;two;2;three;3;4;5,3)

Returns 2.142857 (15/7)
(Back to top)   (Function index)

ListMix(…)

Combine corresponding values from multiple lists into a new list, using a template to process each item.
Description ListMix(template, mode, list1, [list2, ... listN])
  • Argument mode is optional (defaults to 0).

The ListMix() function processes the elements of one or more lists, returning a new list where each element is similar to the provided template modified with the elements of the list argument(s). The number of list arguments to be mixed is variable, but at least one must be provided. The lists can have different lengths, with mode controlling the length of the returned list. The first element of the returned list is generated by applying the first element of each provided list to the template; the second element is generated using the second element(s) of the list(s), and so on until all elements are processed, according to mode.

The template is a text string with placeholders like [L1], [L2], etc, indicating where the elements of the provided lists should be inserted. [L1] refers to elements of list1, [L2] refers to list2, and so on. The special placeholder [N] refers to the item number within the resulting list.

A template is also itself an Expression, so it can contain other functions/expressions. A template can be escaped using the escape sequence /#template#/. This is usually not required but may be useful to enter templates containing functions, commas, or other special symbols.

The default semi-colon list delimiter is used for both input and output lists.

Available mode values:

0Return as many elements as the longest provided list
1Return as many elements as the shortest provided list
2Return as many elements as the first provided list
4Do not evaluate the inner portion as another expression
8Do no unescape after everything
Examples ListMix(Actor #[N] is [L1],, a;b;c)
Returns Actor #1 is a; Actor #2 is b; Actor #3 is c

This example uses mode 0 and demonstrates the usage of [N] and [L1] on a single list.

ListMix([L1][L2]=[L3], 0, a;b;c;d, 1;2;3;4;5, blue;red;green)

Returns a1=blue; b2=red; c3=green; d4=; 5=

Mode 0 returns 5 elements which is the length of the longest list. Note that on the last two the missing values on the template are also missing on the output.

ListMix([L1][L2]=[L3], 1, a;b;c;d, 1;2;3;4;5, blue;red;green)

Returns a1=blue; b2=red; c3=green
Mode 1 returns only 3 elements, the length of the shortest list.

ListMix([L1][L2]=[L3], 2, a;b;c;d, 1;2;3;4;5, blue;red;green)

Returns : a1=blue; b2=red; c3=green; d4=
Mode 2 returns only 4 elements, the length of the first list.

ListMix(FixCase([L1],3)=Math([L2]*[L3]),, aa;bb;cc, 10;20;30, 5;4;3)

Returns : AA=50; BB=80; CC=90
This example uses two different functions on the template to further transform each element of the lists before inserting it into the output.


ListMix(<img src=tooltip:actors\[L1]>, 1, [Actors], 1;2;3;4;5)

Returns (example): <img src=tooltip:actors\Daisy Ridley>;<img src=tooltip:actors\Adam Driver>;<img src=tooltip:actors\John Boyega>;<img src=tooltip:actors\Oscar Isaac>;<img src=tooltip:actors\Mark Hamill>
This example transforms the [Actors] field into a list of <img> tags ready to load the actor thumbnails into the Theather View or Movie Tooltip. It uses mode 1 (shortest list) with a dummy [L2] list of 5 elements to make sure the resulting list is at most 5 items long. An alternative way to accomplish the same would be to use ListLimit([Actors],5) as [L1].
(Back to top)   (Function index)

ListRemove(…)

Removes a string from a list.
Description ListRemove(List, String, List Item, Mode)
  • Argument mode is optional (defaults to 0).

The ListRemove() function removes a given string from a list.

Available mode values:

0Searches for a given string, removing it if found
1Zero-based index mode, will remove the specified list item
2Performs a substring search and remove

Notes

The List Item argument is only required when using Mode 1, remembering that the list items are numbered starting from zero.
When using mode zero, the search performed is case insensitive
When using mode zero, the string to be removed must match the whole list item, otherwise, nothing is removed.
When using mode 1, the List Item zero-based number is specified in place of String.
When using mode 2, wherever the specified substring is found, that entire list entry is removed. See 3rd example below.
Examples listremove(This;Is;a;List,is)
Returns "This;a;List"

This example defaults to mode 0. Note that "is" in "List" and and "This" are not removed, and the search is case insensitive.

listremove(a;b;c;d;e;f;g,5,1)

Returns a;b;c;d;e;g

Mode 1 has been specified, which is a zero-based index mode, so "f" has been removed from the list as it is the fifth list item.

listremove(This;Is;a;List,is,2)

Returns "a"

This example uses mode 2 which performs a substring search for "is", removing This, Is and List, leaving just "a". The search is case insensitive.

(Back to top)   (Function index)

ListShuffle(…)

Shuffles a list.
Description listshuffle(list)

The ListShuffle() function shuffles the given list.

Examples listshuffle(c;b;a)

Shuffles the list, returning some arrangement of the letters.

(Back to top)

ListSort(…)

Sort a list of values.
Description listsort(list, mode, delimiter)

The ListSort() function sorts a list in the order according to mode, using the specified delimiter.

Available mode values:

0Ascending sort
1Descending sort

Argument mode is optional (defaults to 0).

Argument delimiter is optional (defaults to SEMICOLON).

Examples listsort(c;a;b)

Returns a;b;c, using the default ascending mode and (:) delimiter.

listsort(Joe Baxter/, Sally Henson/, Sue Smith, 1, /,)

Returns Sue Smith,Sally Henson,Joe Baxter. Note the requirement to escape the , characters within the list string and in the specified delimiter itself.

listsort([artist];[composer])

Sorts the combined artist and composer lists in ascending order. Note the simple manual construction of a single List by combining the two List type fields, and forcing a ; between the two.

(Back to top)