--- title: "Logic Component" slug: "logic-component" updated: 2023-02-13T09:54:39Z published: 2023-02-13T09:54:39Z canonical: "help.pillir.io/logic-component" --- > ## Documentation Index > Fetch the complete documentation index at: https://help.pillir.io/llms.txt > Use this file to discover all available pages before exploring further. # Logic Component 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. | Input | Output | Block Layout | Generated Code | | --- | --- | --- | --- | | Any Condition in the Hexagonal block | It 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.NoteThe shapes of the blocks allows **any number of else if** sub blocks to be added but only up to **one else block**. | ![ifblock](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/ifblock.png)![](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/image-1628174849283.png) | ```javascript { 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. | Input | Output | Block Layout | JavaScript | | --- | --- | --- | --- | | Variable or Number or Text or both | Boolean (True or False) | ![comparison block icon](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/comparison%20block%20icon.png)![Comparison block](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/Comparison%20block.png) | ```javascript 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. | Input | Output | Block Layout | JavaScript | | --- | --- | --- | --- | | 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-or](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/and-or.png)![not](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/not.png) | ```javascript 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. | Input | Output | Block Layout | JavaScript | | --- | --- | --- | --- | | Boolean block to get a boolean value | Outputs "True" or "False" string values or the numbers "1" and "0" depending on the usage of script. | ![true-false-inside if block](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/true-false-inside%20if%20block.png) | ```javascript 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. | Input | Output | Block Layout | JavaScript | | --- | --- | --- | --- | | NA | Null or Undefined based on selection | ![undefined-null](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/undefined-null.png)NoteThe oval text block can be replaced by any other oval input block. | ```javascript 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. | Input | Output | Block Layout | JavaScript | | --- | --- | --- | --- | | Variable or Text | Boolean( True or False) | ![empty](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/empty.png) | ```javascript 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. | Input | Output | Block Layout | JavaScript | | --- | --- | --- | --- | | 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](https://cdn.document360.io/718af901-247b-46be-8ace-83da21839237/Images/Documentation/ternary%20operator.png) | ```javascript var item; function er_82dd5cda_4b05_447c_a856_6d43bb829825_onPageShow(e,obj,index){ if (item == (false ? null : null)) { } else { } } ``` | ##