Test and Comparison Functions: Difference between revisions

From wiki.jriver.com
Jump to navigation Jump to search
(44 intermediate revisions by the same user not shown)
Line 8: Line 8:


{{function description box
{{function description box
| name=compare
| name=Compare
| arguments=value1, operator, value2
| arguments=value1, operator, value2
| description=
| description=
Line 14: Line 14:


{{argument table
{{argument table
| name=NAME
| name=operator
| contents=
| contents=
{{argument table row|0|ARG0}}
{{argument table row|<nowiki>=</nowiki>|Equivalence}}
{{argument table row|1|ARG1}}
{{argument table row|<nowiki><</nowiki>|Less than}}
{{argument table row|2|ARG3}}
{{argument table row|<nowiki><=</nowiki>|Less than or equal to}}
{{argument table row|3|ARG4}}
{{argument table row|<nowiki>></nowiki>|Greater than}}
{{argument table row|<nowiki>>=</nowiki>|Greater than or equal to}}
}}
}}
Outputs 1 if the comparison is true, and 0 otherwise.
{{argument optional|NAME|0}}
| examples=
| examples=
'''{{monospace|EXAMPLE1}}'''
'''{{monospace|compare([bitrate], &lt;, 320)}}'''
: Returns 1 when the bit rate is less than 320 (Kbps), and 0 otherwise.
: EXAMPLETEXT
'''{{monospace|if(compare(math(now() - [date modified, 0]), &gt;, 21), Expired, formatdate([date modified, 0], elapsed))}}'''
'''{{monospace|EXAMPLE2}}'''
: Outputs the age of files under 21 days old, or {{monospace|Expired}} for older files.
: EXAMPLETEXT
'''{{monospace|EXAMPLE3}}'''
: EXAMPLETEXT
'''{{monospace|EXAMPLE4}}'''
: EXAMPLETEXT
}}
}}

The [[#Compare|Compare()]] function compares two numeric values <i>value1</i> and <i>value2</i> using the specified <i>operator</i>.

Available <i>operator</i> values:

<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>=</b></td><td>Equivalence</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b><</b></td><td>Less than</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b><=</b></td><td>Less than or equal to</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>></b></td><td>Greater than</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>>=</b></td><td>Greater than or equal to</td></tr>
</table></div>

Outputs 1 if the comparison is true, and 0 otherwise.
|- 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;" | {{monospace|<b><nowiki>compare([bitrate], &lt;, 320)</nowiki></b>}}
<p style="margin-left:20pt;">Returns 1 when the bit rate is less than 320 (Kbps), and 0 otherwise.</p>
{{monospace|<b><nowiki>if(compare(math(now() - [date modified, 0]), &gt;, 21), Expired, formatdate([date modified, 0], elapsed))</nowiki></b>}}
<p style="margin-left:20pt;">Outputs the age of files under 21 days old, or {{monospace|Expired}} for older files.</p>
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>


=== <span id="IsEqual">IsEqual(&hellip;)</span> ===
=== <span id="IsEqual">IsEqual(&hellip;)</span> ===
: Compares two values in one of nine specified modes.
: Compares two values in one of nine specified modes.


{{function description box
{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0"
|- id="IsEqual" valign="top"
| name=IsEqual
| arguments=value1, value2, 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>isequal(</b><i>value1</i><b>, </b><i>value2</i><b>, </b><i>mode</i><b>)</b></span>
{{argument optional}}
The [[#IsEqual|IsEqual()]] function compares <i>value1</i> with <i>value2</i> using any <i>mode</i> from the list of modes below.
The [[#IsEqual|IsEqual()]] function compares <i>value1</i> with <i>value2</i> using any <i>mode</i> from the list of modes below.
Outputs 1 when the comparison succeeds according to the <i>mode</i>, and 0 otherwise.
Outputs 1 when the comparison succeeds according to the <i>mode</i>, and 0 otherwise.
Although the <i>mode</i> is specified as the last argument, the comparison should be mentally read as: <i>value1</i> <i>mode</i> <i>value2</i>.
Although the <i>mode</i> is specified as the last argument, the comparison should be mentally read as: <i>value1</i> <i>mode</i> <i>value2</i>.


{{argument table
Available <i>mode</i> values:
| contents=

{{argument table row|0|Case-sensitive string compare for equality}}
<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>0</b></td><td>Case-sensitive string compare for equality</td></tr>
{{argument table row|1|Case-insensitive string compare for equality}}
{{argument table row|2|Numeric compare for equality}}
<tr><td style="text-align:left; padding-right:20pt"><b>1</b></td><td>Case-insensitive string compare for equality</td></tr>
{{argument table row|3|Numeric less than}}
<tr><td style="text-align:left; padding-right:20pt"><b>2</b></td><td>Numeric compare for equality</td></tr>
{{argument table row|4|Numeric less than or equal to}}
<tr><td style="text-align:left; padding-right:20pt"><b>3</b></td><td>Numeric less than</td></tr>
{{argument table row|5|Numeric greater than}}
<tr><td style="text-align:left; padding-right:20pt"><b>4</b></td><td>Numeric less than or equal to</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>5</b></td><td>Numeric greater than</td></tr>
{{argument table row|6|Numeric greater than or equal to}}
{{argument table row|7|Substring search (case sensitive)}}
<tr><td style="text-align:left; padding-right:20pt"><b>6</b></td><td>Numeric greater than or equal to</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>7</b></td><td>Substring search (case sensitive)</td></tr>
{{argument table row|8|Substring search (case insensitive)}}
}}
<tr><td style="text-align:left; padding-right:20pt"><b>8</b></td><td>Substring search (case insensitive)</td></tr>
| examples=
</table></div>
'''{{monospace|<nowiki>isequal([artist], [album], 1)</nowiki>}}'''

: If the artist and album values are the same, the output will be 1, otherwise, the output will be 0.
Argument <i>mode</i> is optional (defaults to 0).
'''{{monospace|<nowiki>if(isequal([artist], [album], 1), Eponymous, [album])</nowiki>}}'''

: The [[If()]] function basis its decision on the outcome of [[IsEqual()]], so if the artist and album values are the same, the output will be Eponymous, otherwise, the output will be the value of album.
|- valign="top"
'''{{monospace|<nowiki>if(isequal([artist], [album], 1), Eponymous/,, [album]/))</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
: This example demonstrates the character escaping mentioned in the overview earlier. Here, we want the output to be either {{monospace|Eponymous,}} (note the inclusion of the comma) or the album value with a closing parenthesis. In order to achieve this, the comma, and the closing parenthesis, are escaped using a forward-slash character. This informs the expression evaluator that these characters are not part of the expression syntax and are to be treated literally.
|style="background: #f9f9f9; color: #111; border-style: solid; border-width: 0px 2px 2px 0; border-top: 1px solid #bbb;" | {{monospace|<b><nowiki>isequal([artist], [album], 1)</nowiki></b>}}
'''{{monospace|<nowiki>if(isequal([filename (path)], classical, 8), Classical, Not Classical)</nowiki>}}'''
<p style="margin-left:20pt;">If the artist and album values are the same, the output will be 1, otherwise, the output will be 0.</p>
: Because compare <i>mode</i> 8 has been specified, if the word {{monospace|classical}} appears anywhere in the case-insensitive file path, the expression will return {{monospace|Classical}}, and if not it will return {{monospace|Not Classical}}.
{{monospace|<b><nowiki>if(isequal([artist], [album], 1), Eponymous, [album])</nowiki></b>}}
}}
<p style="margin-left:20pt;">The [[#If|If()]] function basis its decision on the outcome of [[#IsEqual|IsEqual()]], so if the artist and album values are the same, the output will be Eponymous, otherwise, the output will be the value of album.</p>
{{monospace|<b><nowiki>if(isequal([artist], [album], 1), Eponymous/,, [album]/))</nowiki></b>}}
<p style="margin-left:20pt;">This example demonstrates the character escaping mentioned in the overview earlier.
Here, we want the output to be either {{monospace|Eponymous,}} (note the inclusion of the comma) or the album value with a closing parenthesis.
In order to achieve this, the comma, and the closing parenthesis, are escaped using a forward-slash character.
This informs the expression evaluator that these characters are not part of the expression syntax and are to be treated literally.</p>
{{monospace|<b><nowiki>if(isequal([filename (path)], classical, 8), Classical, Not Classical)</nowiki></b>}}
<p style="margin-left:20pt;">Because compare <i>mode</i> 8 has been specified, if the word {{monospace|classical}} appears anywhere in the case-insensitive file path, the expression will return {{monospace|Classical}}, and if not it will return {{monospace|Not Classical}}.</p>
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>


=== <span id="IsEmpty">IsEmpty(&hellip;)</span> ===
=== <span id="IsEmpty">IsEmpty(&hellip;)</span> ===
: Tests a value for emptiness.
: Tests a value for emptiness.


{{function description box
{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0"
|- id="IsEmpty" valign="top"
| name=IsEmpty
| arguments=value, 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>isempty(</b><i>value</i><b>, </b><i>mode</i><b>)</b></span>
{{argument optional}}
The [[#IsEmpty|IsEmpty()]] function tests the given <i>value</i> for emptiness. The <i>value</i> passed is typically an Media Center field, so that some action may be taken when the field is or is not empty.
Returns 1 when the <i>value</i> is empty, otherwise 0.
The [[#IsEmpty|IsEmpty()]] function tests the given <i>value</i> for emptiness. The <i>value</i> passed is typically an Media Center field, so that some action may be taken when the field is or is not empty. Returns 1 when the <i>value</i> is empty, otherwise 0.


{{argument table
Available <i>mode</i> values:
| contents=
{{argument table row|0|String test (field must be empty to get a positive result).}}
{{argument table row|1|Numerical test (field must be empty, or contain 0 to get a positive result)}}
}}


Note that Media Center does not discriminate between a 0 <i>value</i> and an empty <i>value</i> for fields of type Integer and Decimal - both 0 and empty are considered equivalent for these field types. This is useful for fields such as the integer field Disc #, where an empty or 0 <i>value</i> implies that Disc # contains no useful data, and should be generally ignored or absent in display output.
<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>0</b></td><td>String test (field must be empty to get a positive result)</td></tr>
<tr><td style="text-align:left; padding-right:20pt"><b>1</b></td><td>Numerical test (field must be empty, or contain 0 to get a positive result)</td></tr>
</table></div>

Note that Media Center does not discriminate between a 0 <i>value</i> and an empty <i>value</i> for fields of type Integer and Decimal - both 0 and empty are considered equivalent for these field types.
This is useful for fields such as the integer field Disc #, where an empty or 0 <i>value</i> implies that Disc # contains no useful data, and should be generally ignored or absent in display output.


Pay particular attention to the third example offered below, as it covers a caveat that comes with this particular function.
Pay particular attention to the third example offered below, as it covers a caveat that comes with this particular function.
| examples=

'''{{monospace|<nowiki>isempty([comment], 0)</nowiki>}}'''
Argument <i>mode</i> is optional (defaults to 0).
: If the comment field is empty, [[#IsEmpty|IsEmpty()]] returns 1, otherwise 0.

'''{{monospace|<nowiki>isempty([track #], 1)</nowiki>}}'''
|- valign="top"
: Performs a numerical test for data in the [track #] field. If the field is empty or 0, a 1 is returned, otherwise 0 is returned.
! 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;" | {{monospace|<b><nowiki>isempty([comment], 0)</nowiki></b>}}
'''{{monospace|<nowiki>ifelse(!isempty([disc #]), [disc #])</nowiki>}}'''
: Outputs the <i>value</i> of the disc # field when it is not empty.
<p style="margin-left:20pt;">If the comment field is empty, [[#IsEmpty|IsEmpty()]] returns 1, otherwise 0.</p>
}}
{{monospace|<b><nowiki>isempty([track #], 1)</nowiki></b>}}
<p style="margin-left:20pt;">Performs a numerical test for data in the [track #] field. If the field is empty or 0, a 1 is returned, otherwise 0 is returned.</p>
{{monospace|<b><nowiki>ifelse(!isempty([disc #]), [disc #])</nowiki></b>}}
<p style="margin-left:20pt;">Outputs the <i>value</i> of the disc # field when it is not empty.</p>
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>


=== <span id="IsRange">IsRange(&hellip;)</span> ===
=== <span id="IsRange">IsRange(&hellip;)</span> ===
: Tests a value for inclusion within a given range.
: Tests a value for inclusion within a given range.


{{function description box
{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0"
|- id="IsRange" valign="top"
| name=IsRange
| arguments=value, range
! 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>isrange(</b><i>value</i><b>, </b><i>range</i><b>)</b></span>
The [[#IsRange|IsRange()]] function tests if a <i>value</i> falls within a given <i>range</i> of values.
The [[#IsRange|IsRange()]] function tests if a <i>value</i> falls within a given <i>range</i> of values. If the <i>value</i> falls within the given <i>range</i>, 1 is returned, otherwise 0 is returned.
If the <i>value</i> falls within the given <i>range</i>, 1 is returned, otherwise 0 is returned.


A <i>range</i> is specified in the form of low-high, where low and high are either letters or numbers.
A <i>range</i> is specified in the form of low-high, where low and high are either letters or numbers.
Line 155: Line 114:
<div style="margin-left: 20pt">23-7542 </div>
<div style="margin-left: 20pt">23-7542 </div>
</div>
</div>
| examples=
|- valign="top"
'''{{monospace|<nowiki>isrange([artist], a-c)</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
: Artist values of Abba or Blondie will result in a 1, but ZZ Top will return a 0.
|style="background: #f9f9f9; color: #111; border-style: solid; border-width: 0px 2px 2px 0; border-top: 1px solid #bbb;" | {{monospace|<b><nowiki>isrange([artist], a-c)</nowiki></b>}}
'''{{monospace|<nowiki>if(isrange([bitrate], 96-191), Poor Quality, High Quality)</nowiki>}}'''
<p style="margin-left:20pt;">Artist values of Abba or Blondie will result in a 1, but ZZ Top will return a 0.</p>
: Returns {{monospace|Poor Quality}} for any file whose bit rate falls in the <i>range</i> of 96 to 191, and returns {{monospace|High Quality}} for all other bit rates.
{{monospace|<b><nowiki>if(isrange([bitrate], 96-191), Poor Quality, High Quality)</nowiki></b>}}
'''Additional Examples'''
<p style="margin-left:20pt;">Returns {{monospace|Poor Quality}} for any file whose bit rate falls in the <i>range</i> of 96 to 191, and returns {{monospace|High Quality}} for all other bit rates.</p>

Additional Examples

:[http://wiki.jriver.com/index.php/CD_Reference_Number#Answer_2 Using IsRange() in a Search List.]
:[http://wiki.jriver.com/index.php/CD_Reference_Number#Answer_2 Using IsRange() in a Search List.]
|}
}}
<div style="text-align:right;">([[#top|Back to top)]]</div>


=== <span id="IsMissing">IsMissing(&hellip;)</span> ===
=== <span id="IsMissing">IsMissing(&hellip;)</span> ===
: Tests to see if a file exists on the system.
: Tests to see if a file exists on the system.


{{function description box
{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0"
|- id="IsMissing" valign="top"
| name=IsMissing
| arguments=filepath
! 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>ismissing(</b><i>filepath</i><b>)</b></span>
{{argument optional|filepath|[filename]}}
The [[#IsMissing|IsMissing()]] function tests for the existence of a file in the file system.
If the file is missing, the function returns 1, otherwise 0 is returned if the file exists.
The [[#IsMissing|IsMissing()]] function tests for the existence of a file in the file system. If the file is missing, the function returns 1, otherwise 0 is returned if the file exists. This function is useful for checking for missing files in a Library. [[#IsMissing|IsMissing()]] treats special entries such as ripped Blu-ray or DVDs as single files, even though they physically exist in the file system as several files and directories.
This function is useful for checking for missing files in a Library.
[[#IsMissing|IsMissing()]] treats special entries such as ripped Blu-ray or DVDs as single files, even though they physically exist in the file system as several files and directories.


Note: Any view or list that uses [[#IsMissing|IsMissing()]] will be slow, is Media Center must interrogate each referenced file in the file system.
''Note'': Any view or list that uses [[#IsMissing|IsMissing()]] will be slow, is Media Center must interrogate each referenced file in the file system. The larger the number of files being queried, the longer it will take to produce results. Use [[#IsMissing|IsMissing()]] with care.
| examples=
The larger the number of files being queried, the longer it will take to produce results. Use [[#IsMissing|IsMissing()]] with care.
'''{{monospace|<nowiki>ismissing()</nowiki>}}'''

: If the referenced file was not found in the file system, 1 is returned; otherwise 0 is returned.
Argument <i>filepath</i> is optional (defaults to [filename]).
'''{{monospace|<nowiki>ismissing(C:\Music\My Lost File.mp3)</nowiki>}}'''

: Checks for {{monospace|My Lost File.mp3}} and returns 1 (positive) if the file does not exist, and 0 (negative) if the file does exist.
|- valign="top"
'''{{monospace|if(ismissing(), File is missing, File exists)}}'''
! 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
: Outputs {{monospace|File is missing}} or {{monospace|File Exists}} depending on the result returned by IsMissing().
|style="background: #f9f9f9; color: #111; border-style: solid; border-width: 0px 2px 2px 0; border-top: 1px solid #bbb;" | {{monospace|<b><nowiki>ismissing()</nowiki></b>}}
'''{{monospace|<nowiki>[=ismissing([filename])]=1</nowiki>}}'''
<p style="margin-left:20pt;">If the referenced file was not found in the file system, 1 is returned; otherwise 0 is returned.</p>
: This example demonstrates how to construct an expression for use as a Media Center search query. If you place this in the search field in the top right corner of the program while viewing all of your library, it will filter the list, leaving only the missing files on view. If all files in library exist, this list will be empty. You could also create a view scheme and use this string in the {{monospace|Set rules for file display}} search to give you a view that you can visit periodically to check that your library is not missing any files.
{{monospace|<b><nowiki>ismissing(C:\Music\My Lost File.mp3)</nowiki></b>}}
}}
<p style="margin-left:20pt;">Checks for {{monospace|My Lost File.mp3}} and returns 1 (positive) if the file does not exist, and 0 (negative) if the file does exist.</p>
{{monospace|<b><nowiki>if(ismissing(), File is missing, File exists)</nowiki></b>}}
<p style="margin-left:20pt;">Outputs {{monospace|File is missing}} or {{monospace|File Exists}} depending on the result returned by IsMissing().</p>
{{monospace|<b><nowiki>[=ismissing([filename])]=1</nowiki></b>}}
<p style="margin-left:20pt;">This example demonstrates how to construct an expression for use as a Media Center search query.
If you place this in the search field in the top right corner of the program while viewing all of your library, it will filter the list, leaving only the missing files on view. If all files in library exist, this list will be empty. You could also create a view scheme and use this string in the {{monospace|Set rules for file display}} search to give you a view that you can visit periodically to check that your library is not missing any files.</p>
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>


=== <span id="IsRemovable">IsRemovable(&hellip;)</span> ===
=== <span id="IsRemovable">IsRemovable(&hellip;)</span> ===
: Tests to see if a file is stored on removable media.
: Tests to see if a file is stored on removable media.


{{function description box
{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0"
|- id="IsRemovable" valign="top"
| name=IsRemovable
| arguments=filepath
! 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>isremovable(</b><i>filepath</i><b>)</b></span>
{{argument optional|filepath|[filename]}}
The [[#IsRemovable|IsRemovable()]] function tests if a file resides on removable media and if so, returns 1, and if not, returns 0.
The Media Center field [Removable] also provides the same value for a given file.
The [[#IsRemovable|IsRemovable()]] function tests if a file resides on removable media and if so, returns 1, and if not, returns 0. The Media Center field [Removable] also provides the same value for a given file.
| examples=

'''{{monospace|IsRemovable()}}'''
Argument <i>filepath</i> is optional (defaults to [filename]).
: Checks if the current file is on removable storage, and if so, returns 1, otherwise returns 0.

}}
|- 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;" | {{monospace|<b><nowiki>isremovable()</nowiki></b>}}
<p style="margin-left:20pt;">Checks if the current file is on removable storage, and if so, returns 1, otherwise returns 0.</p>
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>


=== <span id="IsInPlayingNow">IsInPlayingNow(&hellip;)</span> ===
=== <span id="IsInPlayingNow">IsInPlayingNow(&hellip;)</span> ===
: Tests to see if a file is in the Playing Now playlist.
: Tests to see if a file is in the Playing Now playlist.


{{function description box
{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0"
|- id="IsInPlayingNow" valign="top"
| name=IsInPlayingNow
| arguments=filepath
! 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>isinplayingnow(</b><i>filepath</i><b>)</b></span>
{{argument optional|filepath|[filename]}}
The [[#IsInPlayingNow|IsInPlayingNow()]] function tests if a file is in any zone's Playing Now list.
Used as an expression category, pane or file list column allows distinguishing files that are in the Playing Now list.
The [[#IsInPlayingNow|IsInPlayingNow()]] function tests if a file is in any zone's Playing Now list. Used as an expression category, pane or file list column allows distinguishing files that are in the Playing Now list.
| examples=

'''{{monospace|IsInPlayingNow()}}'''
Argument <i>filepath</i> is optional (defaults to [filename]).
: If the file in the Playing Now list, returns 1, otherwise returns 0.

'''{{monospace|<nowiki>if(isinplayingnow(), Queued, Not queued)</nowiki>}}'''
|- valign="top"
: If the file in the Playing Now list, returns {{monospace|Queued}}, otherwise {{monospace|Not queued}}.
! 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;" | {{monospace|<b><nowiki>isinplayingnow()</nowiki></b>}}
<p style="margin-left:20pt;">If the file in the Playing Now list, returns 1, otherwise returns 0.</p>
{{monospace|<b><nowiki>if(isinplayingnow(), Queued, Not queued)</nowiki></b>}}
<p style="margin-left:20pt;">If the file in the Playing Now list, returns {{monospace|Queued}}, otherwise {{monospace|Not queued}}.</p>

Additional Examples

:[http://yabb.jriver.com/interact/index.php?topic=57461.0 How to use IsPlaying() and IsInPlayingNow()]
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>


=== <span id="IsPlaying">IsPlaying(&hellip;)</span> ===
=== <span id="IsPlaying">IsPlaying(&hellip;)</span> ===
: Tests to see if a file is in currently being played.
: Tests to see if a file is in currently being played.


{{function description box
{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0"
|- id="IsPlaying" valign="top"
| name=IsPlaying
| arguments=filepath
! 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>isplaying(</b><i>filepath</i><b>)</b></span>
{{argument optional|filepath|[filename]}}
The [[#IsPlaying|IsPlaying()]] function tests if a file is playing in any zone.
The [[#IsPlaying|IsPlaying()]] function tests if a file is playing in any zone.
Used as an expression category, pane or file list column allows distinguishing files that are playing now.
Used as an expression category, pane or file list column allows distinguishing files that are playing now.
| examples=

'''{{monospace|<nowiki>ifelse(isplaying(), &lt;font color="ff0000"&gt;&#9834;&lt;//font&gt;, isinplayingnow(), &#9834;)</nowiki>}}'''
Argument <i>filepath</i> is optional (defaults to [filename]).
: This expression in a file list expression column shows which files are in the Playing Now list and which are currently playing by outputting a musical note in the column. The musical note will be displayed in red for any currently playing file.

'''Additional Examples'''
|- valign="top"
: [http://yabb.jriver.com/interact/index.php?topic=57461.0 How to use IsPlaying() and IsInPlayingNow()]
! 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
: [http://yabb.jriver.com/interact/index.php?topic=58137.msg393905#msg393905 How to play an artist's full work when a genre is shuffling?]
|style="background: #f9f9f9; color: #111; border-style: solid; border-width: 0px 2px 2px 0; border-top: 1px solid #bbb;" | {{monospace|<b><nowiki>ifelse(isplaying(), &lt;font color="ff0000"&gt;&#9834;&lt;//font&gt;, isinplayingnow(), &#9834;)</nowiki></b>}}
}}
<p style="margin-left:20pt;">This expression in a file list expression column shows which files are in the Playing Now list and which are currently playing by outputting a musical note in the column. The musical note will be displayed in red for any currently playing file.</p>

Additional Examples

:[http://yabb.jriver.com/interact/index.php?topic=57461.0 How to use IsPlaying() and IsInPlayingNow()]

:[http://yabb.jriver.com/interact/index.php?topic=58137.msg393905#msg393905 How to play an artist's full work when a genre is shuffling?]
|}
<div style="text-align:right;">([[#top|Back to top)]]</div>

Revision as of 06:25, 26 January 2016

See also: {{#if:Expression Language |[[:Expression Language{{#if:||{{{l1}}}}}]] |Error: Template must be given at least one article name

}}{{#if:Expression Language#Function Index|{{#if:|, | and }} [[:Expression Language#Function Index{{#if:Function Index||Function Index}}]] }}{{#if:|{{#if:|, |, and }} [[:{{{3}}}{{#if:||{{{l3}}}}}]] }}{{#if:|{{#if:|, |, and }} [[:{{{4}}}{{#if:||{{{l4}}}}}]] }}{{#if:|{{#if:|, |, and }} [[:{{{5}}}{{#if:||{{{l5}}}}}]] }}{{#if:|{{#if:|, |, and }} [[:{{{6}}}{{#if:||{{{l6}}}}}]] }}{{#if:|{{#if:|, |, and }} [[:{{{7}}}{{#if:||{{{l7}}}}}]] }}{{#if:|{{#if:|, |, and }} [[:{{{8}}}{{#if:||{{{l8}}}}}]] }}{{#if:|{{#if:|, |, and }} [[:{{{9}}}{{#if:||{{{l9}}}}}]] }}{{#if:|{{#if:|, |, and }} [[:{{{10}}}{{#if:||{{{l10}}}}}]] }}{{#if:|{{#if:|, |, and }} [[:{{{11}}}{{#if:||{{{l11}}}}}]] }}{{#if:|{{#if:|, |, and }} [[:{{{12}}}{{#if:||{{{l12}}}}}]] }}{{#if:|{{#if:|, |, and }} [[:{{{13}}}{{#if:||{{{l13}}}}}]] }}{{#if:|{{#if:|, |, and }} [[:{{{14}}}{{#if:||{{{l14}}}}}]] }}{{#if:|, and [[:{{{15}}}{{#if: || }}]] }}{{#if:| —
Error: Too many links specified (maximum is 15)

}}

The functions in this section return a Boolean value of either 1 (true) or 0 (false). They are generally used to drive an action specified in one of the Conditional Functions.

Compare(…)

Compares two numbers.
Description Compare(value1, operator, value2)

The Compare() function compares two numeric values value1 and value2 using the specified operator.

Available operator values:

=Equivalence
<Less than
<=Less than or equal to
>Greater than
>=Greater than or equal to

Outputs 1 if the comparison is true, and 0 otherwise.

Examples compare([bitrate], <, 320)
Returns 1 when the bit rate is less than 320 (Kbps), and 0 otherwise.

if(compare(math(now() - [date modified, 0]), >, 21), Expired, formatdate([date modified, 0], elapsed))

Outputs the age of files under 21 days old, or Expired for older files.
(Back to top)   (Function index)

IsEqual(…)

Compares two values in one of nine specified modes.
Description IsEqual(value1, value2, mode)
  • Argument mode is optional (defaults to 0).

The IsEqual() function compares value1 with value2 using any mode from the list of modes below. Outputs 1 when the comparison succeeds according to the mode, and 0 otherwise. Although the mode is specified as the last argument, the comparison should be mentally read as: value1 mode value2.

Available mode values:

0Case-sensitive string compare for equality
1Case-insensitive string compare for equality
2Numeric compare for equality
3Numeric less than
4Numeric less than or equal to
5Numeric greater than
6Numeric greater than or equal to
7Substring search (case sensitive)
8Substring search (case insensitive)
Examples isequal([artist], [album], 1)
If the artist and album values are the same, the output will be 1, otherwise, the output will be 0.

if(isequal([artist], [album], 1), Eponymous, [album])

The If() function basis its decision on the outcome of IsEqual(), so if the artist and album values are the same, the output will be Eponymous, otherwise, the output will be the value of album.

if(isequal([artist], [album], 1), Eponymous/,, [album]/))

This example demonstrates the character escaping mentioned in the overview earlier. Here, we want the output to be either Eponymous, (note the inclusion of the comma) or the album value with a closing parenthesis. In order to achieve this, the comma, and the closing parenthesis, are escaped using a forward-slash character. This informs the expression evaluator that these characters are not part of the expression syntax and are to be treated literally.

if(isequal([filename (path)], classical, 8), Classical, Not Classical)

Because compare mode 8 has been specified, if the word classical appears anywhere in the case-insensitive file path, the expression will return Classical, and if not it will return Not Classical.
(Back to top)   (Function index)

IsEmpty(…)

Tests a value for emptiness.
Description IsEmpty(value, mode)
  • Argument mode is optional (defaults to 0).

The IsEmpty() function tests the given value for emptiness. The value passed is typically an Media Center field, so that some action may be taken when the field is or is not empty. Returns 1 when the value is empty, otherwise 0.

Available mode values:

0String test (field must be empty to get a positive result).
1Numerical test (field must be empty, or contain 0 to get a positive result)

Note that Media Center does not discriminate between a 0 value and an empty value for fields of type Integer and Decimal - both 0 and empty are considered equivalent for these field types. This is useful for fields such as the integer field Disc #, where an empty or 0 value implies that Disc # contains no useful data, and should be generally ignored or absent in display output.

Pay particular attention to the third example offered below, as it covers a caveat that comes with this particular function.

Examples isempty([comment], 0)
If the comment field is empty, IsEmpty() returns 1, otherwise 0.

isempty([track #], 1)

Performs a numerical test for data in the [track #] field. If the field is empty or 0, a 1 is returned, otherwise 0 is returned.

ifelse(!isempty([disc #]), [disc #])

Outputs the value of the disc # field when it is not empty.
(Back to top)   (Function index)

IsRange(…)

Tests a value for inclusion within a given range.
Description IsRange(value, range)

The IsRange() function tests if a value falls within a given range of values. If the value falls within the given range, 1 is returned, otherwise 0 is returned.

A range is specified in the form of low-high, where low and high are either letters or numbers. The lowest value comes first, the highest second. Both low and high must be the same kind (letters or numbers). The low and high values are inclusive.

Some Example Ranges:

1-100
a-z
c-d
23-7542
Examples isrange([artist], a-c)
Artist values of Abba or Blondie will result in a 1, but ZZ Top will return a 0.

if(isrange([bitrate], 96-191), Poor Quality, High Quality)

Returns Poor Quality for any file whose bit rate falls in the range of 96 to 191, and returns High Quality for all other bit rates.

Additional Examples

Using IsRange() in a Search List.
(Back to top)   (Function index)

IsMissing(…)

Tests to see if a file exists on the system.
Description IsMissing(filepath)
  • Argument filepath is optional (defaults to [filename]).

The IsMissing() function tests for the existence of a file in the file system. If the file is missing, the function returns 1, otherwise 0 is returned if the file exists. This function is useful for checking for missing files in a Library. IsMissing() treats special entries such as ripped Blu-ray or DVDs as single files, even though they physically exist in the file system as several files and directories.

Note: Any view or list that uses IsMissing() will be slow, is Media Center must interrogate each referenced file in the file system. The larger the number of files being queried, the longer it will take to produce results. Use IsMissing() with care.

Examples ismissing()
If the referenced file was not found in the file system, 1 is returned; otherwise 0 is returned.

ismissing(C:\Music\My Lost File.mp3)

Checks for My Lost File.mp3 and returns 1 (positive) if the file does not exist, and 0 (negative) if the file does exist.

if(ismissing(), File is missing, File exists)

Outputs File is missing or File Exists depending on the result returned by IsMissing().

[=ismissing([filename])]=1

This example demonstrates how to construct an expression for use as a Media Center search query. If you place this in the search field in the top right corner of the program while viewing all of your library, it will filter the list, leaving only the missing files on view. If all files in library exist, this list will be empty. You could also create a view scheme and use this string in the Set rules for file display search to give you a view that you can visit periodically to check that your library is not missing any files.
(Back to top)   (Function index)

IsRemovable(…)

Tests to see if a file is stored on removable media.
Description IsRemovable(filepath)
  • Argument filepath is optional (defaults to [filename]).

The IsRemovable() function tests if a file resides on removable media and if so, returns 1, and if not, returns 0. The Media Center field [Removable] also provides the same value for a given file.

Examples IsRemovable()
Checks if the current file is on removable storage, and if so, returns 1, otherwise returns 0.
(Back to top)   (Function index)

IsInPlayingNow(…)

Tests to see if a file is in the Playing Now playlist.
Description IsInPlayingNow(filepath)
  • Argument filepath is optional (defaults to [filename]).

The IsInPlayingNow() function tests if a file is in any zone's Playing Now list. Used as an expression category, pane or file list column allows distinguishing files that are in the Playing Now list.

Examples IsInPlayingNow()
If the file in the Playing Now list, returns 1, otherwise returns 0.

if(isinplayingnow(), Queued, Not queued)

If the file in the Playing Now list, returns Queued, otherwise Not queued.
(Back to top)   (Function index)

IsPlaying(…)

Tests to see if a file is in currently being played.
Description IsPlaying(filepath)
  • Argument filepath is optional (defaults to [filename]).

The IsPlaying() function tests if a file is playing in any zone. Used as an expression category, pane or file list column allows distinguishing files that are playing now.

Examples ifelse(isplaying(), <font color="ff0000">♪<//font>, isinplayingnow(), ♪)
This expression in a file list expression column shows which files are in the Playing Now list and which are currently playing by outputting a musical note in the column. The musical note will be displayed in red for any currently playing file.

Additional Examples

How to use IsPlaying() and IsInPlayingNow()
How to play an artist's full work when a genre is shuffling?
(Back to top)   (Function index)