Miscellaneous Functions: Difference between revisions

From wiki.jriver.com
Jump to navigation Jump to search
No edit summary
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 104: Line 104:
: Returns ●
: Returns ●
}}
}}

=== <span id="Counter">Counter(&hellip;)</span> ===
: Counts upwards in specified increments.

{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0"
|- id="Counter" 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>counter(</b><i>start value</i><b>, </b><i>increment</i><b>)</b></span>
The [[#Counter|Counter()]] function outputs a monotonically increasing number (more simply stated, it counts) from a <i>start value</i>,
and each time called, increases by the <i>increment</i> value.
It is useful for sequentially numbering fields.
The [[#Counter|Counter()]] function maintains an internal counter, and it resets itself to zero after five seconds of inactivity.

Because [[#Counter|Counter()]] continues to count, it should only be used in single-use situations such as assigning its output to some field through field value assignment, for example, <span style="font-family: monospace,monospace; font-size:1em;">=counter()</span>.
With proper care, it can be used as part of an expression in the Rename, Move & Copy tool, but see also [[#CustomData|CustomData()]].

It is not recommended for use in any context that continually refreshes its content, such as in a panes column, file list, or expression-based custom query.
Probably the best way to understand the results is to test the first example below as an expression column in a file list, and move the mouse around over that column.

Argument <i>start value</i> is optional (defaults to 1).

Argument <i>increment</i> is optional (defaults to 1).

|- 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>counter()</nowiki></b></span>
<p style="margin-left:20pt;">Outputs values starting at <span style="font-family: monospace,monospace; font-size:1em;">1</span>, and incrementing by one, it will return <span style="font-family: monospace,monospace; font-size:1em;">1</span>, <span style="font-family: monospace,monospace; font-size:1em;">2</span>, <span style="font-family: monospace,monospace; font-size:1em;">3</span>, ... until no longer called.
This might be used, for example, to assign to the [Track #] field of several tracks using the field assignment expression <span style="font-family: monospace,monospace; font-size:1em;">=counter()</span>.</p>
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>padnumber(counter(370, 2), 4)</nowiki></b></span>
<p style="margin-left:20pt;">Outputs numbers beginning from 370, incremented by two each, and padded to four digits. For example, <span style="font-family: monospace,monospace; font-size:1em;">0370</span>, <span style="font-family: monospace,monospace; font-size:1em;">0372</span>, <span style="font-family: monospace,monospace; font-size:1em;">0374</span>, etc.</p>
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>


=== <span id="CustomData">CustomData(&hellip;)</span> ===
=== <span id="CustomData">CustomData(&hellip;)</span> ===
Line 174: Line 142:
<p style="margin-left:20pt;">In and of itself, you might think that this is not 'all that', however, remember that we can combine this with other functions, thus giving us the ability to create expressions with playlist rules. A simple example would be:</p>
<p style="margin-left:20pt;">In and of itself, you might think that this is not 'all that', however, remember that we can combine this with other functions, thus giving us the ability to create expressions with playlist rules. A simple example would be:</p>
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>[=IsEqual(fileplaylists(),genre,8)]=1</nowiki></b></span>
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>[=IsEqual(fileplaylists(),genre,8)]=1</nowiki></b></span>
<p style="margin-left:20pt;">which when used in the search bar, will return all files that appear on a playlist called 'Genre'</p>
<p style="margin-left:20pt;">which when used in the search bar, will return all files that appear on any playlist containing 'Genre' in its name</p>
|}
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>
<div style="text-align:right;">([[#top|Back to top)]]</div>


=== <span id="Math">Math(&hellip;)</span> ===
=== <span id="Literal">Literal(&hellip;)</span> ===
: Returns a string as given without any formatting or processing
: Evaluates a given mathematical formula.

{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0"
|- id="Math" 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>math(</b><i>expression</i><b>)</b></span>
The [[#Math|Math()]] function performs mathematical calculations.
Standard arithmetic operators are supported, as are various numerical, trigonometric, and comparative functions.
Simple variables are supported, as are multiple statements.

<blockquote>
{| style="background: #f9f9f9;" border="1" cellpadding="1" cellspacing="0"
| rowspan="6" width="100" valign="top" | '''Arithmetic Operators'''
| align="center" width="65" | + || Addition
|-
| align="center" | - || Subtraction
|-
| align="center" | * || Multiplication
|-
| align="center" | / || Division
|-
| align="center" | ^ || Power
|-
| align="center" | % || Modulo
|-
| rowspan="3" | '''Boolean Operators'''
| align="center" | ! || NOT
|-
| align="center" | & || AND
|-
| align="center" | <nowiki>|</nowiki> || OR
|-
| rowspan="1" | '''Grouping Operators'''
| align="center" | ( ) || Precedence grouping
|-
| rowspan="4" | '''Comparison Operators'''
| align="center" | } || Absolute value maximum (i.e. x or y that is maximum distance from 0).
|-
| align="center" | { || Absolute value minimum (i.e. x or y that is minimum distance from 0).
|-
| align="center" | > || Distance between x and y, positive when x greater than y, negative otherwise.
|-
| align="center" | < || Distance between x and y, positive when x less than y, negative otherwise.
|-
| rowspan="7" | '''Functions'''
| align="center" | abs(x) || Returns the absolute value of x.
|-
| align="center" | sign(x) || Returns the sign of x (1 when x >= 0, -1 when x < 0).
|-
| align="center" | log(x) || Returns the natural logarithm (base e) of x.
|-
| align="center" | log10(x) || Returns the common logarithm (base 10) of x.
|-
| align="center" | pow(x,y) || Returns x raised to the y-th power.
|-
| align="center" | rand(x,y) || Returns a random value ranging between x and y.
|-
| align="center" | randn(x) || Returns a random value ranging between -x and x.
|-
| rowspan="5" | '''Comparison Functions'''
| align="center" | min(x,y) || Returns the minimum value of x and y.
|-
| align="center" | max(x,y) || Returns the maximum value of x and y.
|-
| align="center" | equal(x,y) || Returns 1 when x = y, 0 otherwise.
|-
| align="center" | below(x,y) || Returns 1 when x < y, 0 otherwise.
|-
| align="center" | above(x,y) || Returns 1 when x > y, 0 otherwise.
|-
| rowspan="4" | '''Formatting Functions'''
| align="center" | int(x) || Returns the integer portion of x.
|-
| align="center" | frac(x) || Returns the fractional portion of x.
|-
| align="center" | round(x) || Returns x rounded to the nearest whole number.
|-
| align="center" | trunc(x,n) || Returns x truncated to n decimal places.
|-
| rowspan="6" | '''Trigonometric Functions'''
| align="center" | atan(x) || Returns the arctangent of x.
|-
| align="center" | cos(x) || Returns the cosine of x.
|-
| align="center" | sin(x) || Returns the sine of x.
|-
| align="center" | tan(x) || Returns the tangent of x.
|-
| align="center" | abscos(x) || Returns the absolute value of cosine(x).
|-
| align="center" | abssin(x) || Returns the absolute value of sin(x).
|}
</blockquote>

The order of operator precedence is summarized as follows, from top to bottom:

<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>(&nbsp;&nbsp;&nbsp;)</b></td><td>&nbsp;</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>&nbsp;&nbsp;!</b></td><td>&nbsp;</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>&nbsp;&nbsp;^</b></td><td>&nbsp;</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>*&nbsp;&nbsp;&nbsp;/</b></td><td>Left to right</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>+&nbsp;&nbsp;&nbsp;-</b></td><td>Left to right</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b><nowiki>|</nowiki>&nbsp;&nbsp;&nbsp;&amp;</b></td><td>Left to right</td></tr>
</table></div>

Variables may be assigned and used by specifying a simple string of letters. Examples: <span style="font-family: monospace,monospace; font-size:1em;">math(val=2)</span> or <span style="font-family: monospace,monospace; font-size:1em;">math(x=pow(2,3))</span>.

Multiple equations may be specified, each separated by a semicolon.
Expressions are evaluated left to right.
The final value of the [[#Math|Math()]] function will be the result of the right-most equation. For example, the equation <span style="font-family: monospace,monospace; font-size:1em;">math(x=4; pow(2^x))</span> will output 16.

<b>Note</b>: Empty fields

Fields used inside of [[#Math|Math()]] are expanded (interpolated) directly.
Fields with empty values may produce incomplete [[#Math|Math()]] statements.
For example, if the field [number plays] is empty, an <i>expression</i> such as <span style="font-family: monospace,monospace; font-size:1em;">math([number plays] + 2)</span> would be seen
by [[#Math|Math()]] as <span style="font-family: monospace,monospace; font-size:1em;"> + 2</span>.
This incomplete <i>expression</i> would produce a syntax error. See the Additional Examples for more information.

<b>Note</b>: Locales and Commas

Special care must be taken with the [[#Math|Math()]] function and locales that use <span style="font-family: monospace,monospace; font-size:1em;">,</span> (comma) as a decimal separator.
Many Media Center fields and the return values from functions may contain comma as the decimal point.
Your expressions will need to [[#Replace|Replace()]] these before passing the values to [[#Math|Math()]],
which always uses dot <span style="font-family: monospace,monospace; font-size:1em;">.</span> as the numeric decimal point.

For example, the <i>expression</i> <span style="font-family: monospace,monospace; font-size:1em;">math(1,5 + 1,5)</span> will fail since [[#Math|Math()]] does not consider <span style="font-family: monospace,monospace; font-size:1em;">1,5</span> to be a valid number.

Fields that cause problems are any fields that produce floating-point values, such as any Date type field in raw format
(e.g. <span style="font-family: monospace,monospace; font-size:1em;">[date,0]</span>, <span style="font-family: monospace,monospace; font-size:1em;">[last played,0]</span>, <span style="font-family: monospace,monospace; font-size:1em;">[date modified,0]</span>, and <span style="font-family: monospace,monospace; font-size:1em;">[date imported,0]</span>), or any textual field that contains
floating-point values that will be used for various calculations (e.g. any of the Dynamic Range variants).
Certain functions such as [[#Now|Now()]] and [[#ConvertTime|ConvertTime()]] also return localized floating-point values.

Handling this problem is not difficult.
Before passing any floating point number to [[#Math|Math()]], use [[#Replace|Replace()]] first. See the examples below.
|- 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>math(10 + 4)</nowiki></b></span>
<p style="margin-left:20pt;">Returns 14.</p>
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>math(10 + 2 * 25)</nowiki></b></span>
<p style="margin-left:20pt;">Returns 60, demonstrating that multiplication has higher precedence than addition.</p>
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>math((10 + 2) * 25)</nowiki></b></span>
<p style="margin-left:20pt;">Returns 300, demonstrating that parenthesis grouping has higher precedence than multiplication.</p>
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>math(replace(now(), /,, .) - replace([last played,0], /,, .))</nowiki></b></span>
<p style="margin-left:20pt;">The <span style="font-family: monospace,monospace; font-size:1em;">,</span> is replaced by a <span style="font-family: monospace,monospace; font-size:1em;">.</span> in the output of both [[#Now|Now()]] and in the raw field value <span style="font-family: monospace,monospace; font-size:1em;">[last played,0]</span>.
Note that the comma must be escaped so that it is seen as an argument and not as an argument separator.</p>
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>math(replace(now() - [last layed,0], /,, .))</nowiki></b></span>
<p style="margin-left:20pt;">The same as the previous example, but is more efficient and simpler since it calls [[#Replace|Replace()]] just once on the entire string to be passed to [[#Math|Math()]].</p>

Additional Examples

:[http://yabb.jriver.com/interact/index.php?topic=58110.0 An explanation and some solutions for fields that evaluate to empty within Math().]
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>

=== <span id="Number">Number(&hellip;)</span> ===
: Returns the first number , including decimals, from a given string


{{function description box
{{function description box
| name=Number
| name=Literal
| arguments=String
| arguments=String
| description=
| description=
[[#Literal|Literal()]] returns a given string as-is without any formatting or processing
Returns the first number , including decimals, from a given string. If there are other numbers along the string, these will not be returned as the function stops once it encounters and returns the first number. <i>String</i> can be given literally, as a library field, or combined with other expression functions.


| examples=
| examples=
'''{{monospace|If(IsEqual([Artist], Queen, 1), Literal(If all music was Queen, I would be 10/10ths happy!), Literal(This is not Queen, which makes me sad. :-/))}}'''
'''{{monospace|Number(The number12 will be returned, but 13 will not)}}'''
: This does not work, with the sad face breaking the expression completely and generating an error. It should work, suggesting that the Literal() function is currently broken.
: This expression will return 12 and stop. It will not see the number 13.
: This reference will be updated once clarification has been received. In the meantime, as detailed under [[Expression Language#Expression Language Syntax|Expression Language Syntax]], using /* ... /* does work as Literal() is expected to. See next example...

'''{{monospace|/*Left(Theater,3) returns/* Left(Theater,3)}}'''
: Returns {{monospace|Left(Theater,3) returns The}}. Here, the first expression function is not evaluated and instead, presented as given, whilst the second function, which is not escaped, is evaluated. Escaping text in this way could be useful if working with a large block of text that might contain parenthesis, forward slashes or other characters that would otherwise require to be escaped individually.
}}
}}


=== <span id="Rand">Rand(&hellip;)</span> ===
=== <span id="Repeat">Repeat(&hellip;)</span> ===
: Repeats a given string a specified number of times
: Returns a random number between two given numbers


{{function description box
{{function description box
| name=Rand
| name=Repeat
| arguments=x, y, mode
| arguments=Value, Count
| description=
| description=
Repeats {{monospace|"Value", "Count"}} number of times.
{{argument optional|Mode|0|}}
: '''x''' = start number (can be a negative value)
: '''y''' = end number (can be a negative value)
{{argument table
| contents=
{{argument table row|0|Returns a random value between x and y to 15 decimal places ''(Default mode)''}}
{{argument table row|1|Returns a random value between x and y, whole numbers only.}}
}}
Rand() returns a random value between x and y. x and y must be numbers and can have negative values.

Rand() is not recommended for use in any context that continually refreshes its content, such as in a panes column, file list, or expression-based custom query. Probably the best way to understand the results is to test the first example below as an expression column in a file list, and move the mouse around over that column.

| examples=
| examples=
'''{{monospace|Rand(0,1)}}'''
'''{{monospace|<nowiki>Repeat(*,10)</nowiki>}}'''
: Returns **********
: This will return a random value between 0 and 1, to fifteen decimal places. ''Mode'' has not been specified, and so defaults to zero.


'''{{monospace|Rand(-10,10,1)}}'''
'''{{monospace|<nowiki>Repeat(Ha,5)</nowiki>}}'''
: Returns HaHaHaHaHa
: ''Mode'' 1 has been specified, so this will return a random, whole number value between -10 and 10.
}}
}}

=== <span id="Range">Range(&hellip;)</span> ===
: Creates a semi-colon delimited list of numbers in a field.

{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0"
|- id="Range" 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>Range(</b><i>Start</i><b>, </b><i>Step</i><b>, </b><i>Count</i><b>)</b></span>
The [[#Range|Range()]] function returns a list of semi-colon separated numbers into one field, starting at the <i>Start</i> number, incrementing by the <i>Step</i> number, producing <i>Count</i> numbers.

Arguments <i>Start</i> and <i>Step</i> are optional (default to 0 Zero), and can be negative.

Argument <i>Count</i> is required and must be positive.

|- 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>Range(1, 1, 10)</nowiki></b></span>
<p style="margin-left:20pt;">Returns <span style="font-family: monospace,monospace; font-size:1em;">1;2;3;4;5;6;7;8;9;10</span>.</p>
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>Range(5, -1, 6)</nowiki></b></span>
<p style="margin-left:20pt;">Returns <span style="font-family: monospace,monospace; font-size:1em;">5;4;3;2;1;0</span>.</p>
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>


=== <span id="Row">Row(&hellip;)</span> ===
=== <span id="Row">Row(&hellip;)</span> ===
Line 437: Line 220:
<div style="text-align:right;">([[#top|Back to top)]]</div>
<div style="text-align:right;">([[#top|Back to top)]]</div>


=== <span id="StackCount">StackCount(&hellip;)</span> ===
=== <span id="Translate">Translate(&hellip;)</span> ===
: Converts an English string found in the program to the current language selected in the language menu
: Returns the number of files in a stack


{{function description box
{{function description box
| name=StackCount
| name=Translate
| arguments=
| arguments=String
| description=
| description=
When using Media Center with any language ''other than English'', the Translate() function can be used to translate an English string in the program to the current language.
StackCount() does not require any arguments and is used to return the number files in a stack. This is useful, for example, if you are creating custom tooltips and want that information in there or for inclusion in a view you could create to view and manage your stacks, something you might use heavily if you stack a lot of photos or regularly sync files to a handheld device using the ''convert format'' options available there. Note that some files can appear in multiple databases.


| examples=
| examples=
'''{{monospace|<nowiki>StackCount()</nowiki>}}'''
'''{{monospace|<nowiki>Translate(Keywords)</nowiki>}}'''
: If using the French language setting, this will return Mots-clés
: Create a panes view where the "Set rules for file display" contains only ''-[Stack Top]=-1 ~d=mk'' and nothing else. Add categories to this view as suits, but, make the first one an expression category using the given example, and the second one, a simple expression ''=[stack top], which makes it possible to filter the file list by individual stacks selection.
'''<u>Important Note</u>'''<br>
This should be considered an advanced user approach, where it is <u>''very''</u> important that you understand the differences in how Media Center behaves when stacks are either collapsed or expanded. [https://yabb.jriver.com/interact/index.php/topic,105662.0.html This forum post] should help in that regard.
}}
}}


=== <span id="TrackNumber">TrackNumber(&hellip;)</span> ===
=== <span id="TreeNode">TreeNode(&hellip;)</span> ===
: Returns a file's track # value.
: Returns the selected tree path.

{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0"
|- id="TrackNumber" 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>tracknumber(</b><b>)</b></span>
The [[#TrackNumber|TrackNumber()]] function returns a file's track #, or 0 if the no value exists.
It is used to populate the Library field <span style="font-family: monospace,monospace; font-size:1em;">track #</span> with its value.
Either the field or [[#TrackNumber|TrackNumber()]] can be used.
|- 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>tracknumber()</nowiki></b></span>
<p style="margin-left:20pt;">Returns the value present in the <span style="font-family: monospace,monospace; font-size:1em;">track #</span> field.</p>
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>

=== <span id="Translate">Translate(&hellip;)</span> ===
: Converts an English string found in the program to the current language selected in the language menu


{{function description box
{{function description box
| name=Translate
| name=TreeNode
| arguments=String
| arguments=Mode
| description=
| description=
{{argument optional}}
When using Media Center with any language ''other than English'', the Translate() function can be used to translate an English string in the program to the current language.
{{argument table
| name=mode
| contents=
{{argument table row|0|Returns the full tree path}}
{{argument table row|1|Returns the currently selected tree node}}
{{argument table row|2|Returns the parent of the currently selected tree node}}
}}


| examples=
| examples=
'''{{monospace|<nowiki>Translate(Keywords)</nowiki>}}'''
'''{{monospace|<nowiki>TreeNode()</nowiki>}}'''
: Will return the full tree path of the currently selected tree item (Uses mode zero by default)
: If using the French language setting, this will return Mots-clés

What this function does is self-explanatory. '''[https://yabb.jriver.com/interact/index.php/topic,128134.msg888957.html#msg888957 This conversation]''' on the Interact forums demonstrates a practical use-case scenario.
}}
}}



Latest revision as of 05:44, 5 June 2021

The functions in this section are varied and have specialized applicability. Some are primarily used internally by MC to generate values available in various Library fields.

AlbumArtist(…)

Returns a file's calculated album artist.
Description albumartist()

The AlbumArtist() function calculates the album artist value used in various views and fields. It is used to populate the Library field album artist (auto) with its value. Either the field or AlbumArtist() can be used.

Examples albumartist()

Returns the value present in the album artist (auto) field.

Additional Examples

Describes the algorithm used by AlbumArtist() to calculate the "album artist (auto)" field's value.
(Back to top)

AlbumKey(…)

Returns a unique album key for a file.
Description albumkey()

The AlbumKey() function returns "[album artist (auto)] - [album]". It is a convenience function, used to return the generally unique album / artist combination string used to distinguish between two like-named albums such as "Greatest Hits".

Examples albumkey()

For an album named Greatest Hits and an album artist (auto) of The Eagles, returns The Eagles - Greatest Hits.

(Back to top)

AlbumType(…)

Returns the album type for a file.
Description albumtype()

The AlbumType() function returns a description regarding an album's completeness and its quantity of artists. It is used to populate the Library field album type with its value. Either the field or AlbumType() can be used.

Examples albumtype()

Returns, for example, Single artist (complete), or Multiple artists (incomplete).

(Back to top)

AudioAnalysisState(…)

Returns the state of audio analysis for a file.
Description audioanalysisstate()

The AudioAnalysisState() function returns a file's state of audio analysis. It can be used to determine if audio analysis (Library Tools > Analyze Audio...) should be performed on a media file. The AudioAnalysisState() function will return a string indicating the state of analysis. Possible values are currently:

NeededAudio analysis is needed
DoneAudio analysis is complete
N/AThe file type does not support audio analysis
Excluded (No Audio)The file type supports analysis, but contains no audio
Failed on <date>Audio analysis failed on the <date> specified
Examples audioanalysisstate()

Returns, for example, Needed for files that require audio analysis, or N/A if the file type does not support audio analysis.

Additional Examples

Describes the improved audio analysis and R128 volume leveling feature.
(Back to top)

Char(…)

Returns a character from the numeric code of that character
Description Char(Numeric Number Code)

Char() has unicode support, however, only decimal values are supported. If you require a Hex to Decimal convertor, try unicode-search.net, or search for an alternative online.

Examples Char(189)
Returns ½

Char(9679)

Returns ●
(Back to top)   (Function index)

CustomData(…)

Returns internal data to the expression language.
Description customdata(mode)

The CustomData() function supports returning Media Center internal data to the expression language. Currently the only supported mode provides a file's row number in a file list, which is useful in the Rename, Move & Copy tool to assist in numbering files. It can also be used in expressions in a playlist to obtain the file's sequence number.

Available mode values:

#Returns a file's row number in a file list
Examples Spring_Break_Bash_padnumber(customdata(#), 4)

In the Rename, Move & Copy tool, each consecutive file would be named Spring_Break_Bash_ followed by a four digit, zero-padded number starting at 0001.

(Back to top)

FilePlaylists()

Returns a list of playlists a file belongs to.
Description FilePlaylists()

This function returns the list of playlists a file is in separated by semi-colons.

Examples FilePlaylists()

Using this will return a list of all the playlists a file is in, separated by semi-colons.

In and of itself, you might think that this is not 'all that', however, remember that we can combine this with other functions, thus giving us the ability to create expressions with playlist rules. A simple example would be:

[=IsEqual(fileplaylists(),genre,8)]=1

which when used in the search bar, will return all files that appear on any playlist containing 'Genre' in its name

(Back to top)

Literal(…)

Returns a string as given without any formatting or processing
Description Literal(String)

Literal() returns a given string as-is without any formatting or processing

Examples If(IsEqual([Artist], Queen, 1), Literal(If all music was Queen, I would be 10/10ths happy!), Literal(This is not Queen, which makes me sad. :-/))
This does not work, with the sad face breaking the expression completely and generating an error. It should work, suggesting that the Literal() function is currently broken.
This reference will be updated once clarification has been received. In the meantime, as detailed under Expression Language Syntax, using /* ... /* does work as Literal() is expected to. See next example...

/*Left(Theater,3) returns/* Left(Theater,3)

Returns Left(Theater,3) returns The. Here, the first expression function is not evaluated and instead, presented as given, whilst the second function, which is not escaped, is evaluated. Escaping text in this way could be useful if working with a large block of text that might contain parenthesis, forward slashes or other characters that would otherwise require to be escaped individually.
(Back to top)   (Function index)

Repeat(…)

Repeats a given string a specified number of times
Description Repeat(Value, Count)

Repeats "Value", "Count" number of times.

Examples Repeat(*,10)
Returns **********

Repeat(Ha,5)

Returns HaHaHaHaHa
(Back to top)   (Function index)

Row(…)

Returns the row number of a list entry
Description Row()

Row() returns the row number for each item in a list.

Examples Row()
When used as an expression column in a file list, each row is numbered starting at 1, incrementing by 1.
(Back to top)   (Function index)

Size(…)

Returns a file's size in a format specific to the media type.
Description size()

The Size() function returns media size information specific to the particular media type. It is used to populate the Library fields duration and dimensions with their values. Either the field or Size() can be used.

Type of information reported by size for the file's media type:

AudioDuration
VideoDuration
ImageDimensions
DataNo information returned.
Examples size()

Returns values such as 400x225 for images, or 3:09 for audio files.

(Back to top)

Translate(…)

Converts an English string found in the program to the current language selected in the language menu
Description Translate(String)

When using Media Center with any language other than English, the Translate() function can be used to translate an English string in the program to the current language.

Examples Translate(Keywords)
If using the French language setting, this will return Mots-clés
(Back to top)   (Function index)

TreeNode(…)

Returns the selected tree path.
Description TreeNode(Mode)
  • Argument mode is optional (defaults to 0).

Available mode values:

0Returns the full tree path
1Returns the currently selected tree node
2Returns the parent of the currently selected tree node
Examples TreeNode()
Will return the full tree path of the currently selected tree item (Uses mode zero by default)

What this function does is self-explanatory. This conversation on the Interact forums demonstrates a practical use-case scenario.

(Back to top)   (Function index)

TVInfo(…)

Miscellaneous television and other pre-formatted information.
Description tvinfo(type)

The TVInfo() function is multi-purpose, and returns a specific type of information about television recordings, programs, and pre-formatted informational strings for use in captions, thumbnails, grouping, etc.

Available type values:

IsProgramReturns 1 if the file is a program, 0 otherwise
IsGuideProgramReturns 1 if the file is a guide program, 0 otherwise
IsRecordedProgramReturns 1 if the file is a recorded program, 0 otherwise
IsTVChannelReturns 1 if the selection is a TV Channel program
ChannelReturns the channel name associated with a given program
ChannelKeywordsReturns channel keywords
ChannelProgramNowReturns the name of a playing TV program on a given channel, empty otherwise
DateReturns a program's date
DateNoTimeSame as Date, but without the time.
NameDisplayReturns [name]: [series] or just [name]
NameDisplayWithDateNameDisplay + ([year])
RecordReturns 1 if the program is scheduled to be recorded, 0 otherwise
RecordMarkReturns a red dot if the program is schedule to be recorded.
RecordStatusReturns a string describing the record status, blank if not to be recorded.
SeriesDisplayReturns [series] or [name]
SeasonDisplayReturns [season]
SeasonEpisodeReturns [season].[episode]
TimeDisplayReturns program start time (system time format), or "Showing" if program on now
TimeDisplayNoOnNowTimeDisplay without on now handling
SizeDisplayReturns [duration] ([file size]) or [dimensions] ([file size])
WatchedDisplayReturns Watched() information, such as No, Yes, 80%, etc.
IsOnNonTopGroupedChannelReturns 1 if an EPG program is on a channel that is grouped as a non-top member, 0 otherwise.
ProgramChannelNumberReturns channel number of the television channel the program is on.
Examples tvinfo(namedisplay)

Returns formatted name and series output. If the file has no [series] value, only [name] is output.

(Back to top)