Difference between revisions of "Scripting"

From Memento Database Wiki
Jump to: navigation, search
m
m
Line 1: Line 1:
{{Stamp|2017-01-13|4.2.1|1.0.7}}
+
{{Stamp|2021-04-13-23|4.10.0|1.10.0}}
 
+
''[[This page is a stub, with some tidbits. A more complete page is forthcoming.]]''
+
  
 
== Native Memento Calculation scripting ==
 
== Native Memento Calculation scripting ==
Line 10: Line 8:
  
 
=== The '''[[JavaScript field]]''' type ===
 
=== The '''[[JavaScript field]]''' type ===
'''[[TBD]]'''
+
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''.
 +
 
 +
==== Terminology ====
 +
:; Constant:a value that has a string (text) value or a numeric (number) value.
 +
<small>
 +
::; String:"This is a string of textual characters"
 +
::; Number:123 or 3.14 or -28.5
 +
::; Symbol:a name representing a constant value, like pi, x, tareWeight, or surname
 +
</small>
 +
:; Variable:a name representing a value that may change over time, like ''sum'', ''currentValue'', or ''orderDate''
 +
:; Operator: one or more characters that represent the value of other values that go together in some fashion to determine a result, like '''+''' for ''plus'' or '''-''' for ''minus'' or '''*''' for ''multiplied by'' or '''/''' for ''divided by''. :::Some operators are made up of other operators used in combination, like '''<=''' ''for less than or equal to'' or '''&&''' for ''and also''.
 +
 
 +
==== JavaScript field script examples ====
 +
:123; any numeric constant
  
 
=== JavaScript scripting for [[Triggers|'''Memento Triggers''']] ===
 
=== JavaScript scripting for [[Triggers|'''Memento Triggers''']] ===

Revision as of 01:49, 24 April 2021

« Page as of 2021-04-13-23, editions Mobile 4.10.0, Desktop 1.10.0 »

Native Memento Calculation scripting

Scripting for the Calculation field type is described in Calculation field.

Scripting Memento in JavaScript

Scripting in JavaScript is available in JavaScript field and Triggers.

The JavaScript field type

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.

Terminology

Constant
a value that has a string (text) value or a numeric (number) value.

String
"This is a string of textual characters"
Number
123 or 3.14 or -28.5
Symbol
a name representing a constant value, like pi, x, tareWeight, or surname

Variable
a name representing a value that may change over time, like sum, currentValue, or orderDate
Operator
one or more characters that represent the value of other values that go together in some fashion to determine a result, like + for plus or - for minus or * for multiplied by or / for divided by. :::Some operators are made up of other operators used in combination, like <= for less than or equal to or && for and also.

JavaScript field script examples

123; any numeric constant

JavaScript scripting for Memento Triggers

TBD

moment.min.js — a possibly useful wrapper for JavaScript dates & times

See http://momentjs.com and its subordinate pages Guides and Docs.

Tidbit
To get the current date, use moment().toDate(). To get the current date & time, use moment().toDate().getTime().

TBD