Write, Bureaucrats, Administrators
4,332
edits
mNo edit summary |
mNo edit summary |
||
Line 12: | Line 12: | ||
Like the Memento Calculation field type that game before it, the JavaScript field exists to produce ("return") a value calculated with an ''expression'', which is a formula consisting of ''constants'', ''variables'', ''operators'', and possibly ''statements''. | Like the Memento Calculation field type that game before it, the JavaScript field exists to produce ("return") a value calculated with an ''expression'', which is a formula consisting of ''constants'', ''variables'', ''operators'', and possibly ''statements''. | ||
==== | ==== Sample simple expression scripts ==== | ||
:;123: the value ''a hundred and twenty-three'' | :;123: the value ''a hundred and twenty-three'' | ||
:;"Memento": the characters ''M e m e n t o'' as a string | :;"Memento": the characters ''M e m e n t o'' as a string | ||
:; 2 * currentWeight: If currentWeight is 23 lbs, then 46 lbs | :; 2 * currentWeight: If currentWeight is 23 lbs, then 46 lbs | ||
:; (hours * 60) + 10:If hours is 5 and minutes is 10, then 310 | :; (hours * 60) + 10:If hours is 5 and minutes is 10, then 310 | ||
==== Sample more complex expression scripts ==== | |||
:'''Validate entered value:''' | |||
<pre> | |||
var StdLimit = 100 // Our std for all products | |||
value = field("Value") // Fetch value of field | |||
if (value <= StdLimit) // If within limit, | |||
value // Result is the value | |||
else // Otherwise, | |||
StdLimit // Result is the std limit | |||
</pre> | |||
==== Terminology ==== | ==== Terminology ==== |