Accessing and Storing Functions: Difference between revisions
Line 109: | Line 109: | ||
: Adds to a global variable. |
: Adds to a global variable. |
||
{{function description box |
|||
{| style="width: 100%; border-spacing: 0; border: 0px solid black;" align="top" cellpadding="3" cellspacing="0" |
|||
| name=saveadd |
|||
|- valign="top" |
|||
| arguments=variable, 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>saveadd(</b><i>variable</i><b>, </b><i>value</i><b>, </b><i>mode</i><b>)</b></span> |
|||
The [[#SaveAdd|SaveAdd()]] function adds <i>value</i> to a global <i>variable</i> either numerically or as a list item. |
The [[#SaveAdd|SaveAdd()]] function adds <i>value</i> to a global <i>variable</i> either numerically or as a list item. |
||
The <i>mode</i> argument indicates how <i>variable</i> is modified. |
The <i>mode</i> argument indicates how <i>variable</i> is modified. |
||
{{argument table |
|||
Available <i>mode</i> values: |
|||
| name=mode |
|||
| contents= |
|||
<div style="margin-left: 20pt;"><table style="border-spacing:0px; border-collapse:collapse; background: #f9f9f9"> |
|||
{{argument table row|0|Add numeric <i>value</i> (integer or decimal) to <i>variable</i>}} |
|||
{{argument table row|1|Append string <i>value</i> as a list item to <i>variable</i>}} |
|||
{{argument table row|2|Prepend string <i>value</i> as a list item to <i>variable</i>}} |
|||
⚫ | |||
</table></div> |
|||
{{argument optional|mode|0}} |
|||
| examples= |
|||
Argument <i>mode</i> is optional (defaults to 0). |
|||
'''{{monospace|saveadd(v, 1)}}''' |
|||
: Numerically increments the global <i>variable</i> {{monospace|v}} by {{monospace|1}}. |
|||
|- valign="top" |
|||
'''{{monospace|saveadd(v, math(2 - 6))}}''' |
|||
! 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>saveadd(v, 1)</nowiki></b></span> |
|||
'''{{monospace|load(foo, v)saveadd(v, bar, 1)load(v)}}''' |
|||
<p style="margin-left:20pt;">Numerically increments the global <i>variable</i> <span style="font-family: monospace,monospace; font-size:1em;">v</span> by <span style="font-family: monospace,monospace; font-size:1em;">1</span>.</p> |
|||
: Loads <i>value</i> {{monospace|foo}} into <i>variable</i> {{monospace|v}}, then appends the <i>value</i> {{monospace|bar}} as a list item, and the final {{monospace|load(v)}} expression outputs the result of {{monospace|foo; bar}}. |
|||
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>saveadd(v, math(2 - 6))</nowiki></b></span> |
|||
'''{{monospace|load(That, v)saveadd(v, This, 2)load(v)}}''' |
|||
⚫ | |||
⚫ | |||
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>load(foo, v)saveadd(v, bar, 1)load(v)</nowiki></b></span> |
|||
}} |
|||
<p style="margin-left:20pt;">Loads <i>value</i> <span style="font-family: monospace,monospace; font-size:1em;">foo</span> into <i>variable</i> <span style="font-family: monospace,monospace; font-size:1em;">v</span>, then appends the <i>value</i> <span style="font-family: monospace,monospace; font-size:1em;">bar</span> as a list item, and the final <span style="font-family: monospace,monospace; font-size:1em;">load(v)</span> expression outputs the |
|||
result of <span style="font-family: monospace,monospace; font-size:1em;">foo; bar</span>.</p> |
|||
<span style="font-family: monospace,monospace; font-size:1em;"><b><nowiki>load(That, v)saveadd(v, This, 2)load(v)</nowiki></b></span> |
|||
⚫ | |||
⚫ | |||
<div style="text-align:right;">([[#top|Back to top)]]</div> |
|||
=== <span id="Tag">Tag(…)</span> === |
=== <span id="Tag">Tag(…)</span> === |
Revision as of 03:21, 24 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:
| ||||
---|---|---|---|---|---|
Examples | field(album)
field(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)
save(math(1 + 2), sum)load(sum)
|
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.
|
---|---|
Examples | note(phone)
note(phone, home)
note(phone, home)
note(phone, home, 1))
|
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]". Available mode values:
| ||||
---|---|---|---|---|---|
Examples | save(Much Money, local_bank)
save(More Money, My Bank, 1)
save(math([duration,0] / 60), durmins)if(compare([durmins], >, 5.0), Long Track, Short Track)
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:
| ||||||
---|---|---|---|---|---|---|---|
Examples | saveadd(v, 1)
saveadd(v, math(2 - 6))
load(foo, v)saveadd(v, bar, 1)load(v)
load(That, v)saveadd(v, This, 2)load(v)
|
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. |