Skip to main content

FieldLogs

Basic

The Basic category includes three types of Script Instructions.

  1. Evaluating an expression

  2. Block Structures

  3. Comments

Expression Eval: Expression Eval is a Basic Instruction that executes a JavaScript expression and stores the result in a Local Variable.

To construct a Script Instruction using Expression Eval:

  1. Select Expression Eval from the Instruction dropdown list. Options Variable Name and Expression appear as seen below.

    ExpressionEvalintro.png
  2. Enter the name of the Local Variable and the JavaScript Expression in the respective fields.

    In the below example:

    The Local Variable updatedCount holds the Expression var(deviceCount) + 10;

    ExpressionEval1.png

    The Expression Eval Script Instruction is added to the Script.

    ExpressionEval2.png

At runtime, if the value of deviceCount is 5, then this Script Instruction executes the Expression ( deviceCount + 10 = 5 + 10 ) and stores the value of 15 in the Local Variable updatedCount.

Note

Expression Eval can be also used to evaluate string and logical expressions.

Block {...} : {...} adds structure to the Script. A Block holds a set of Script Instructions.

Note

The Block Structure { ... } also defines the scope of a Local Variable. A Local Variable defined inside a Block is only accessible to Script Instructions within the same Block.

To create a Block Structure:

  1. Select { ... } from the Instruction dropdown list.

    Blocks1.png

    A Block Structure appears in the Script.

    Blocks2.png
  2. You can add new Script Instructions to the Block by clicking the blocksplus.png button. You can remove the Block by clicking the blocksminus.png button.

    blockplusminus.png

Using the Block Structure, you can organize the Script in a logical manner.

In the below example, note that the Script has been organized into Blocks.

Block3.png

Comment // ... : // ... adds a non-executable statement to the Script. It can be used to add helpful notes and explanations to the Script.

Adding Comments increases the readability of the Script. You can add as many Comments as required.

To add a Comment:

  1. Select // ... from the Instruction dropdown list.

    Comments1.png
  2. Enter the comment in the Comment field.

    Comments2.png

A comment is added to the Script. Comments are usually added to provide information related to the other Instructions in the Script as seen below:

ScriptsComments.png