--- title: "Logic Block" slug: "logic-blocks" updated: 2022-10-20T09:45:14Z published: 2022-10-20T09:45:14Z canonical: "help.pillir.io/logic-blocks" --- > ## 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 Block ## 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 first condition is false. | Input | Output | Block Layout | Generated Code | | --- | --- | --- | --- | | Any Condition in a 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. 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](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 for 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) for both | 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) | ```javascript var item; function er_82dd5cda_4b05_447c_a856_6d43bb829825_onPageShow(e,obj,index){ if (item == undefined) { } else { } } var item; function er_82dd5cda_4b05_447c_a856_6d43bb829825_onPageShow(e,obj,index){ if (item == null) { } else { } } ``` | ## 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) Note The oval text block can be replaced by any other oval input block. | ```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 { } } ``` | ##