Logic Component
  • 13 Feb 2023
  • 3 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Logic Component

  • Dark
    Light
  • PDF

Article summary

The following blocks are present in the Logic component of the App Behavior:

If, If-Else condition blocks: 

  • Use if to specify a block of code to be executed, if a specified condition is true.
  • Use else to specify a block of code to be executed, if a specified condition is false.
  • Use else if to specify a new condition to test, if the previous condition is false.
InputOutputBlock LayoutGenerated Code
Any Condition in the Hexagonal blockIt will execute the True or False statement.
The if-else or else block can be added when the settings icon is clicked.
An if block may have any number of else if sections. Conditions are evaluated top to bottom until one is satisfied, or until no more conditions are left.
Note
The shapes of the blocks allows any number of else if sub blocks to be added but only up to one else block.


ifblock
{
   if (false) {
  } else if (false) {
  } else {
  }

}

Comparison Operator blocks:

  • This block is used to do the comparison operations.
  •  There are six comparison operators - Equals, Not equals, Greater than, Greater than or equals, Less than, Less than or equals.  
  • Comparison operators can be used in conditional statements or within loops to compare values and take action depending on the result.
  • They are used in logical statements to determine equality or difference between variables or values.
InputOutputBlock LayoutJavaScript
Variable or Number or Text or bothBoolean (True or False)comparison block iconComparison block
function er_82dd5cda_4b05_447c_a856_6d43bb829825_onPageShow(e,obj,index){
   if (0 == 0) {
  }

}
function er_82dd5cda_4b05_447c_a856_6d43bb829825_onPageShow(e,obj,index){
   if (0 != 0) {
  }

}
function er_82dd5cda_4b05_447c_a856_6d43bb829825_onPageShow(e,obj,index){
   if (0 < 0) {
  }

}
function er_82dd5cda_4b05_447c_a856_6d43bb829825_onPageShow(e,obj,index){
   if (0 <= 0) {
  }

}
function er_82dd5cda_4b05_447c_a856_6d43bb829825_onPageShow(e,obj,index){
   if (0 > 0) {
  }
}
function er_82dd5cda_4b05_447c_a856_6d43bb829825_onPageShow(e,obj,index){
   if (0 >= 0) {
  }

}

Logical Operator blocks:

Logical operators are used to determine the logic between two or more conditions. It is used to do the following operations: Logical AND, Logical OR, Logical NOT.

InputOutputBlock LayoutJavaScript
Boolean (True or False) The and block will return true only if both of its two inputs are also true.

The or block will return true if either of its two inputs are true.

The not block converts its Boolean input into its opposite.


and-ornot
function er_82dd5cda_4b05_447c_a856_6d43bb829825_onPageShow(e,obj,index){
   if (false && false) {
  }

}
function er_82dd5cda_4b05_447c_a856_6d43bb829825_onPageShow(e,obj,index){
   if (false || false) {
  }

}
function er_82dd5cda_4b05_447c_a856_6d43bb829825_onPageShow(e,obj,index){
   if (!true) {
  } else {
  }

}

Boolean block

The Boolean block has two values - True or False. The boolean values can also be stored in variables and passed to functions, the same as number, text, and list values.

InputOutputBlock LayoutJavaScript
Boolean block to get a boolean valueOutputs "True" or "False" string values or the numbers "1" and "0" depending on the usage of script.true-false-inside if block
function er_82dd5cda_4b05_447c_a856_6d43bb829825_onPageShow(e,obj,index){
   if (true) {
  } else {
  }

}
function er_82dd5cda_4b05_447c_a856_6d43bb829825_onPageShow(e,obj,index){
   if (false) {
  } else {
  }

}

Get Null or Undefined block:

The undefined block is used within a comparison block to check if a variable is undefined or not and outputs a Null or Undefined value on a selection.

InputOutputBlock LayoutJavaScript
NANull or Undefined based on selectionundefined-null
Note
The oval text block can be replaced by any other oval input block.


var item;


async function er_e5ef0ba7_4bcb_4140_8392_e1b0fd53df82_onPageShow(e,obj,index){
   if (item == undefined) {

    /**
    'Report Error'
    **/
  }

}
var item;


async function er_e5ef0ba7_4bcb_4140_8392_e1b0fd53df82_onPageShow(e,obj,index){
   if (item == null) {

    /**
    'Report Error'
    **/
  }

}

Check Empty block:

Checks if the given variable(or Array) or string in selection is empty or not. 

InputOutputBlock LayoutJavaScript
Variable or TextBoolean( True or False)empty
function er_82dd5cda_4b05_447c_a856_6d43bb829825_onPageShow(e,obj,index){
   if (!'Test'.length) {
  } else {
  }

}

Ternary Condition block:

A ternary operator is a conditional operator that assigns a value to a variable based on some condition. Checks If True, or If False conditions.

InputOutputBlock LayoutJavaScript

Boolean (True or False) for the test 

variable or number or Text for both true and false block


Returns variable or number or Text of true or false block depending on the condition.


ternary operator
var item;


function er_82dd5cda_4b05_447c_a856_6d43bb829825_onPageShow(e,obj,index){
   if (item == (false ? null : null)) {
  } else {
  }

}




Was this article helpful?

ESC

Eddy AI, facilitating knowledge discovery through conversational intelligence