Accessing and Storing Functions: Difference between revisions
No edit summary |
|||
Line 7: | Line 7: | ||
:Returns a field's value. |
:Returns a field's value. |
||
{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0" |
|||
{{Function Description Box|field|name, mode}} |
|||
|- 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>field(</b><i>name</i><b>, </b><i>mode</i><b>)</b></span> |
|||
The [[#Field|Field()]] function returns the value stored in field <i>name</i>. |
The [[#Field|Field()]] function returns the value stored in field <i>name</i>. |
||
The format of return is selected by <i>mode</i>. |
The format of return is selected by <i>mode</i>. |
||
Line 19: | Line 22: | ||
Argument <i>mode</i> is optional (defaults to 1). |
Argument <i>mode</i> is optional (defaults to 1). |
||
|- valign="top" |
|||
{{Function Example Box}} |
|||
! 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 |
|||
{{Function Example Item|field(album)}} |
|||
|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>field(album)</nowiki></b></span> |
|||
<p style="margin-left:20pt;">Returns the formatted value of field <i>name</i> <span style="font-family: monospace,monospace; font-size:1em;">album</span>. |
<p style="margin-left:20pt;">Returns the formatted value of field <i>name</i> <span style="font-family: monospace,monospace; font-size:1em;">album</span>. |
||
Note that this is equivalent to <span style="font-family: monospace,monospace; font-size:1em;">[album]</span>.</p> |
Note that this is equivalent to <span style="font-family: monospace,monospace; font-size:1em;">[album]</span>.</p> |
||
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>field(date, 0)</nowiki></b></span> |
|||
{{Function Example Item|field(date, 0)}} |
|||
<p style="margin-left:20pt;">Returns the raw, unformatted value stored in the <span style="font-family: monospace,monospace; font-size:1em;">date</span> field. |
<p style="margin-left:20pt;">Returns the raw, unformatted value stored in the <span style="font-family: monospace,monospace; font-size:1em;">date</span> field. |
||
Note that this is equivalent to <span style="font-family: monospace,monospace; font-size:1em;">[date,0]</span>.</p> |
Note that this is equivalent to <span style="font-family: monospace,monospace; font-size:1em;">[date,0]</span>.</p> |
Revision as of 21:23, 23 January 2016
- See also: Expression Language and Function Index
The functions in this section access field values, store and load global variables, access file tags, and access note fields.
Field(…)
- Returns a field's value.
Description | field(name, mode)
The Field() function returns the value stored in field name. The format of return is selected by mode. Available mode values:
Argument mode is optional (defaults to 1). | ||||
---|---|---|---|---|---|
Examples | field(album)
Returns the formatted value of field name album. Note that this is equivalent to [album]. field(date, 0) Returns the raw, unformatted value stored in the date field. Note that this is equivalent to [date,0]. |
Load(…)
- Outputs the value of a global variable.
Description | load(varname)
Loads and outputs the value of the specified global variable varname that has been previously stored with Save(). |
---|---|
Examples | load(var1)
Loads and outputs the previous stored value of the global variable named var1. If var1 has not been previously stored, the output will be empty. save(math(1 + 2), sum)load(sum) Saves the output of the Math() function into sum, and then loads and outputs the value of sum, which is 3. |
Note(…)
- Retrieve note fields.
Description | note(field label, field type, occurrence)
The Note() function retrieves information from a Media Center Note. Specifically, it returns the contents associated with a field label, of a given field type. The Nth occurrence may be requested. Notes data may be simple text, or associated with defined a field label. Currently the only type of field label is contact information. The first line of a Note is associated with the omnipresent field label Name. The field type selects the specific sub-type for a given field label, and occurrence selects which instance of several field label / field type pairs is returned. The occurrence value is zero-based. Argument field type is optional (defaults to FIRST AVAILABLE). Argument occurrence is optional (defaults to 0). |
---|---|
Examples | note(phone)
Returns the value found in the first Phone field label. If no Phone label exists, nothing is returned. note(phone, home) Returns the value found in the first Home field type from the Phone field label. If the Phone label, Home type does not exists, nothing is returned. note(phone, home, 1) Same as the previous example, but the second instance of the field type is selected instead of the first, since occurrence is zero-based. |
Save(…)
- Saves a value to a global variable.
Description | save(value, variable, mode)
This Save() function saves the value into the specified global variable, and optionally will return that value if mode is set. Once a global variable has been created using Save(), that variable's value is available for use with either Load() or the pseudo-field "[variable]".
Argument mode is optional (defaults to 0). | ||||
---|---|---|---|---|---|
Examples | save(Much Money, local_bank)
Saves the value Much Money into the global variable local_bank. save(More Money, My Bank, 1) Saves More Money into My Bank and outputs the variables value More Money. save(math([duration,0] / 60), durmins)if(compare([durmins], >, 5.0), Long Track, Short Track) Saves the calculated duration in minutes into the variable durmins. Notice that subsequent expressions fragments such as the if(compare()...) may now use the pseudo-field [durmins] as shorthand for load(durmins). Additional Examples |
SaveAdd(…)
- Adds to a global variable.
Description | saveadd(variable, value, mode)
The SaveAdd() function adds value to a global variable either numerically or as a list item. The mode argument indicates how variable is modified. Available mode values:
Argument mode is optional (defaults to 0). | ||||||
---|---|---|---|---|---|---|---|
Examples | saveadd(v, 1)
Numerically increments the global variable v by 1. saveadd(v, math(2 - 6)) Numerically increments the global variable v by the outcome of the Math(), which is -4. load(foo, v)saveadd(v, bar, 1)load(v) Loads value foo into variable v, then appends the value bar as a list item, and the final load(v) expression outputs the result of foo; bar. load(That, v)saveadd(v, This, 2)load(v) Similar to the previous example, but using the prepend mode, resulting in the output This; That. |
Tag(…)
- Returns a file's physical tag.
Description | tag(tag name)
The Tag() function reads and returns the value of tag name directly from a file. The Media Center Library database is not used with Tag(), and instead the specified file is read for the requested tag. The spelling and letter case of the tag name must match exactly those stored in the file. Performance note: This function must open and read the actual file, so its performance is significantly slower than other functions which operate on database fields. |
---|---|
Examples | tag(My Personal Tag)
This will return the value from the tag named My Personal Tag from file referenced by the [filename] field. tag(Gapless Header) Returns the Gapless Header tag value, often contained in an mp3 file. tag(exif: Date) Returns the raw date data from the EXIF data saved inside a jpg file. |