Test and Comparison Functions: Difference between revisions
No edit summary |
No edit summary |
||
Line 28: | Line 28: | ||
'''{{monospace|if(compare(math(now() - [date modified, 0]), >, 21), Expired, formatdate([date modified, 0], elapsed))}}''' |
'''{{monospace|if(compare(math(now() - [date modified, 0]), >, 21), Expired, formatdate([date modified, 0], elapsed))}}''' |
||
: Outputs the age of files under 21 days old, or {{monospace|Expired}} for older files. |
: Outputs the age of files under 21 days old, or {{monospace|Expired}} for older files. |
||
}} |
|||
=== <span id="FieldQuery">FieldQuery(…)</span> === |
|||
: Return a list of matches based on a list of fields to search, from a selected scope of files. |
|||
{{function description box |
|||
| name=FieldQuery |
|||
| arguments=fieldlist, valuelist, return, mode, scope |
|||
| description= |
|||
The [[#FieldQuery|FieldQuery()]] function returns a list of matches based on a list of fields to search, from a selected scope of files.. |
|||
* Fieldlist: a semi-colon delimited list of fields to search, e.g. Director;Studio |
|||
* Valuelist: a value to search for in each field in fieldlist (could be an expression) |
|||
* Return: The single field that is returned when a match is found, values from files returned as a semi-colon delimited list |
|||
* {{argument table |
|||
| name=mode |
|||
| contents= |
|||
{{argument table row|0|Contains}} |
|||
{{argument table row|1|Exact Match}} |
|||
}} |
|||
* {{argument table |
|||
| name=scope |
|||
| contents= |
|||
{{argument table row|0|Current View (faster results - only search files in the current view)}} |
|||
{{argument table row|1|Global (searches all files)}} |
|||
}} |
|||
'''<u>Important Notes</u>''' |
|||
* When providing the value(s) for '''Fieldlist''', library fields are referenced by their names only. i.e., <u>no square brackets.</u> |
|||
* If a library field is desired for use in '''Valuelist''', <u>square brackets are required.</u> |
|||
* When performing searches in list type fields, such as [Actors], each entry in the field list is tested for either 'contains' or 'exactness', as specified, rather than the raw field data. |
|||
* The current implementation returns matches in ANY of the given fields (OR). AND is not possible at this time. [[https://yabb.jriver.com/interact/index.php/topic,124543.msg899283.html#msg899283 Reference]] |
|||
| examples= |
|||
'''{{monospace|FieldQuery(Director,Ridley Scott,Name,1,1)}}''' |
|||
: This queries the [Director] field of ''all'' files for exactly "Ridley Scott", returning a list of names for all positive results: ''Alien;Blade Runner;Gladiator'' |
|||
'''{{monospace|FieldQuery(Actors,Al Pacino,Name,0,0)}}''' |
|||
: This queries the [Actors] field of the currently listed files for any containing "Al Pacino", returning a list of names for all positive results: ''The Godfather;Heat;Scarface;The Irishman'' |
|||
'''{{monospace|fieldquery(Director;Actors, Sean Penn;Nicole Kidman, Name, 1, 0)}}''' |
|||
: this returns all files where Sean Penn OR Nicole Kidman is in the Director OR Actors field |
|||
}} |
}} |
||
Latest revision as of 15:50, 5 June 2021
- See also: Expression Language and Function Index
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:
Outputs 1 if the comparison is true, and 0 otherwise. | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Examples | compare([bitrate], <, 320)
if(compare(math(now() - [date modified, 0]), >, 21), Expired, formatdate([date modified, 0], elapsed))
|
IsDigit(…)
- Determines whether or not a given value is digits.
Description | IsDigit(value, characters)
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)
isdigit(Check1-2)
|
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:\)
isdrivemissing(C:)
if(IsDriveMissing(V:),Please Connect Drive [volume name],Files are availble)
|
IsEmpty(…)
- Tests a value for emptiness.
Description | IsEmpty(value, mode)
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:
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)
isempty([track #], 1)
ifelse(!isempty([disc #]), [disc #])
|
IsEqual(…)
- Compares two values in one of seventeen specified modes.
Description | IsEqual(value1, value2, mode)
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:
| ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Examples | isequal([artist], [album], 1)
if(isequal([artist], [album], 1), Eponymous, [album])
if(isequal([artist], [album], 1), Eponymous/,, [album]/))
if(isequal([filename (path)], classical, 8), Classical, Not Classical)
if(isequal([Genre], Pop;Rock, 9), Pop or some sort of Rock, Not Pop or Rock)
if(isequal([Genre], Pop;Rock, 11), Some sort of Pop Rock, Not Pop Rock)
if(isequal([Genre], Pop;Rock, 13), Pop or some sort of Rock, Not Pop or Rock)
if(isequal([Genre], Pop;Rock, 15), Some sort of Pop Rock, Not Pop Rock)
|
IsInPlayingNow(…)
- Tests to see if a file is in the Playing Now playlist.
Description | IsInPlayingNow(filepath)
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(isinplayingnow(), Queued, Not queued)
|
IsLowerCase(…)
- Tests to see if a value is lower case.
Description | IsLowerCase(value, characters)
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)
IsLowerCase(tesT,3)
IsLowerCase(tesT)
|
IsMissing(…)
- Tests to see if a file exists on the system.
Description | IsMissing(filepath)
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()
ismissing(C:\Music\My Lost File.mp3)
if(ismissing(), File is missing, File exists)
[=ismissing([filename])]=1
|
IsPlaying(…)
- Tests to see if a file is in currently being played.
Description | IsPlaying(filepath)
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(), ♪)
Additional Examples |
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)
if(isrange([bitrate], 96-191), Poor Quality, High Quality)
Additional Examples |
IsRemovable(…)
- Tests to see if a file is stored on removable media.
Description | IsRemovable(filepath)
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()
|
IsUpperCase(…)
- Tests to see if a value is upper case.
Description | IsUpperCase(value, characters)
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)
IsUpperCase(TESt,3)
IsUpperCase(TESt)
|
SearchTags(…)
- Finds all fields that contain a value
Description | SearchTags(value, mode)
Available mode values:
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)
SearchTags(Beatles, 1)
[=SearchTags(Beatles, 1)]=1
|