Comment on page
The Boolean block in the GraphLinq IDE is a fundamental building block that represents the Boolean data type, which can have two possible values: "true" or "false". Booleans are commonly used in programming as a means of making decisions and controlling the flow of a program based on certain conditions.
The Boolean block does not have any inputs. Instead, it serves as a static value block that can be connected to other blocks in a graph.
The Boolean block has one output parameter that represents the Boolean value. This output can be connected to other blocks that accept Boolean values as input.
The Boolean block is primarily used for making logical decisions within a graph. By connecting the Boolean block's output to a branch or conditional block, developers can control the flow of execution based on whether the value is "true" or "false".
Suppose a graph is designed to check whether a user is logged in. The graph might have a login check block that returns a Boolean value indicating whether the user is logged in or not.
Based on the output of the login check block (which is "true" in this case), the graph can follow different paths. For example, if the user is logged in (Boolean value is "true"), the graph may proceed to display personalized content. If the user is not logged in (Boolean value is "false"), the graph may redirect the user to the login page.
In another scenario, a graph might use a Boolean block to control a loop. For instance, a graph could have a loop that continues to execute as long as a certain condition is true.
When the Boolean value is "false," the loop will terminate, and the graph will proceed to the next set of instructions.
Note: The Boolean block plays a crucial role in decision-making and flow control within graphs. By providing a simple "true" or "false" value, developers can create logic that responds to specific conditions, making their graphs dynamic and responsive to different scenarios. Whether used for conditional branching or loop control, the Boolean block is an essential tool for building versatile and interactive graphs.
The Boolean block in the GraphLinq IDE allows users to enter boolean values ("true" or "false"), which serve as conditions to determine the execution flow of the graph. These boolean values act as control signals, guiding the graph to follow specific yellow lines based on their true or false status.
In the above example, "true" has been typed into the
Booleanblock, which is then being sent as the input data into the
Boolean Branchblock. When the
Boolean Branchblock is run, it will trigger the top yellow connection to fire next, since that output corresponds with the "true" value it received as input. Therefore, the topmost
The example above, while very simple, is not very realistic, because no matter what, the top output of the
Boolean Branchwill fire every time we run this graph, since we hard-coded its condition to be simply the value "true". The
Boolean Branchblocks in the above example are therefore pointless.
In this example, we are using a
String Branchblock to check if two given strings are equal. If they are equal, it triggers the top
Set variableblock, which uses a
Booleanblock to assign the value "true" to a variable called "theStringsMatch" (if a variable by that name doesn't exist yet, then this will also declare a variable by that name). If the two strings are not the same, it instead executes the bottom
Set variableblock, which assigns the value "false" to the same variable.
Later, in the right side of the image, we can see an example of that same boolean variable being accessed with a
Get variableblock, and the value of that variable is then used as the input to a
Boolean Branchblock, which will determine which of its outputs will be executed.This is an example of controlling the flow of our graph using a boolean variable whose value is not known to the developer when they make the graph, but is instead calculated only once the graph is running.
Note: the values for
Booleanblocks are not case-sensitive, so they work with "true", "True", "false", and "False". If you were to type anything besides those values into the
Booleanblock above, then neither of the
Boolean Branchoutputs would execute.