Test and Comparison Functions

From wiki.jriver.com
(Redirected from IsEmpty())
Jump to navigation Jump to search

The majority of 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)

IsDigit(…)

Determines whether or not a given value is digits.
Description IsDigit(value, characters)
  • Argument Characters is optional (defaults to all).

The IsDigit() function tests the given value to determine whether or not it is digits, returning "1" for a positive result, and "0" for a negative (not digits) result.

Examples isdigit(1234)
Returns "1" as these are all digits.

isdigit(Check1-2)

Returns "0" as these are not all digits.
(Back to top)   (Function index)

IsDriveMissing(…)

Tests for the prescence of a specified drive.
Description IsDriveMissing(Drive)

The IsDriveMissing() function tests for the prescence of a specified drive, returning "1" for a positive (missing) result, and "0" for a negative (drive exists) result. Note that this function cannot work with drive names at all, only drive letters.

Examples isdrivemissing(C:\)
Returns "0" as drive C: is available.

isdrivemissing(C:)

Returns "0" as drive C: is available. Demonstrating the backslash is not essential for the function to operate correctly.

if(IsDriveMissing(V:),Please Connect Drive [volume name],Files are availble)

Returns "Please Connect Drive V:" for all files residing on drive V: if it is missing, or, Files are availble if the drive is connected.
(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)

IsEqual(…)

Compares two values in one of seventeen 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)
9List search ANY (case sensitive)
10List search ANY (case insensitive)
11List search ALL (case sensitive)
12List search ALL (case insensitive)
13List search ANY (case sensitive) (Full String Match)
14List search ANY (case insensitive) (Full String Match)
15List search ALL (case sensitive) (Full String Match)
16List search ALL (case insensitive) (Full String Match)
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 bases 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.

if(isequal([Genre], Pop;Rock, 9), Pop or some sort of Rock, Not Pop or Rock)

Because compare mode 9 has been specified, if either of the case sensitive sub-strings Rock or Pop appear anywhere in the Genre List Type field, the expression will return Pop or some sort of Rock, and if not it will return Not Pop or Rock.
Genres that match include "Pop" "Rock" "Pop;Rock" "Pop Rock" "Rock;Pop" "Popular;Rock" "Popular;Rock & Roll" "Rock & Roll" "Funk Rock" and "Alt. Rock", among others.

if(isequal([Genre], Pop;Rock, 11), Some sort of Pop Rock, Not Pop Rock)

Because compare mode 11 has been specified, if the case sensitive sub-strings Pop and Rock both appear anywhere in the Genre List Type field, the expression will return Some sort of Pop Rock, and if not it will return Not Pop Rock.
Genres that match include "Pop;Rock" "Pop Rock" "Rock;Pop" "Popular;Rock" and "Popular;Rock & Roll", among others.
Genres that do not match include "Pop" "Rock" "Rock & Roll" "Funk Rock" and "Alt. Rock", among others.

if(isequal([Genre], Pop;Rock, 13), Pop or some sort of Rock, Not Pop or Rock)

Because compare mode 13 has been specified, if either of the case sensitive full strings Rock or Pop appear in the Genre List Type field, the expression will return Pop or some sort of Rock, and if not it will return Not Pop or Rock.
Genres that match include "Pop;Rock" "Pop;Rock & Roll" "Popular;Rock", among others.
Genres that do not match include "Pop Rock" "Rock & Roll" "Rock, Popular" "Popular;Rock & Roll" "Funk Rock" and "Alt. Rock", among others.

if(isequal([Genre], Pop;Rock, 15), Some sort of Pop Rock, Not Pop Rock)

Because compare mode 15 has been specified, if the case sensitive full strings Pop and Rock both appear in the Genre List Type field, the expression will return Some sort of Pop Rock, and if not it will return Not Pop Rock.
Genres that match include "Pop;Rock" "Pop;Electronic;Rock" "Rock;Pop,Alt.Rock" "Rock;Pop" and "Rock;Punk;Pop", among others.
Genres that do not match include "Pop" "Rock" "Popular;Rock" and "Pop;Rockabilly", among others.
(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)

IsLowerCase(…)

Tests to see if a value is lower case.
Description IsLowerCase(value, characters)
  • Argument Characters is optional (defaults to all).

The IsLowerCase() function tests the given value to determine whether or not it is lower case, returning "1" for a positive result, and "0" for a negative result.

Examples IsLowerCase(tesT,1)
Returns "1" as only one character is specified for the check, and the first character, is lower case.

IsLowerCase(tesT,3)

Returns "1" as the first three characters are lower case.

IsLowerCase(tesT)

Returns "0" as here, all characters will be tested, and one of them is not lower case.
(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)

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)

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

See also: DateInRange(…)

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)

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)

IsUpperCase(…)

Tests to see if a value is upper case.
Description IsUpperCase(value, characters)
  • Argument Characters is optional (defaults to all).

The IsUpperCase() function tests the given value to determine whether or not it is upper case, returning "1" for a positive result, and "0" for a negative result.

Examples IsUpperCase(TESt,1)
Returns "1" as only one character is specified for the check, and the first character, is upper case.

IsUpperCase(TESt,3)

Returns "1" as the first three characters are upper case.

IsUpperCase(TESt)

Returns "0" as here, all characters will be tested, and one of them is not upper case.
(Back to top)   (Function index)

SearchTags(…)

Finds all fields that contain a value
Description SearchTags(value, mode)
  • Argument mode is optional (defaults to 0).

Available mode values:

0Returns a semi-colon delimited list of fields
1Returns 1 for a positive result and 0 for a negative result

The SearchTags() function tests for a value in any field and returns the list of fields it is in, or a binary for further processing. Note that this function tests the raw value in the field, and not the formatted value, so matches against numerical values such as date fields may give unexpected results.

Also, this function searches every field for all files in the current View or Playlist, so it will not be fast in some uses.

Examples SearchTags(Beatles, 0)
If the file includes any tag that contains "Beatles", then the function returns the list of fields, such as "Artist; Filename".

SearchTags(Beatles, 1)

If the file includes any tag that contains "Beatles", then the function returns 1, otherwise 0.

[=SearchTags(Beatles, 1)]=1

Used in a search, finds all files that contains "Beatles" in any field.
(Back to top)   (Function index)