Blawx User Interface Tour
In Blawx you encode laws by sticking puzzle pieces together on a table. The table is called your “workspace”. The place you grab the puzzle pieces from is called the “toolbox.”
In the picture below, the area outlined in green is the toolbox, and the area on the right is the workspace.
The toolbox is made up of categories. When you click on a category name, the blocks available in that category are displayed. If the category has sub-categories, a black triangle appears before the name of the category.
Usually, most of the blocks in a category will match the highlight colour on the left side of the category.
At the top of the workspace is a resizeable, transparent area that shows the results received from the Blawx reasoner.
The individual puzzle pieces that you use to encode laws are called “Blocks”, or “Blawx”. Blocks can include information that you can’t change, like the words “is an Object” in the Object Declaration block shown below, and they can include information that you can change, like the word “rock” in the image below.
Information that you can change in a block is called a field. The field above is a text field that allows you to type information into it. There are also fields for numbers, which is a text field that you can only type numbers into.
And there are dropdown fields, that allow you to choose one of several options. One example is the true/false block.
There are two kinds of connectors on the blocks in in Blawx (say that 5 times fast!): “insert” connectors, and “and” connectors. Each has a positive and negative version.
The positive “insert” connector looks like the sticky-outie part of a puzzle piece and sticks out of the left side of the block.
Th negative insert connector looks like a “hole” where the positive insert connector would fit. Most of these locations show up as a missing puzzle piece inside a larger block.
The size of the hole doesn’t matter, and will expand to fit whatever block connects to it.
Occasionally, the connector is on the outside of another block, like this:
When Insert Connectors “Don’t Fit”
Blawx tries to help make sure that you don’t stick things where they don’t belong. So as an example, if you try to stick a number where Blawx is expecting a string, the blocks won’t “fit properly.” Just like when you’re doing a jigsaw puzzle and you’re trying to stick two pieces together that don’t belong together… it just doesn’t quite work.
If you’re trying to insert a block and it “won’t fit”, you are probably trying to insert a block that is of the wrong datatype.
Whenever you use an insert connector, it has the same meaning as “filling in the blank”. Most blocks will not work if any of their negative insert connectors are empty. If there’s a blank, you need to fill it.
The “And” connectors, which are show as a divot (negative) on the top of a block and a bump (positive) on the bottom of a block.
Blocks with “and” connectors can be stacked with each other vertically. When you stack two things vertically using the “and” connector, that has the same effect as using an And block.
Means exactly the same thing as this:
You can see that the And block has four and connectors. It has a negative on the top and a positive on the bottom, so it can be stacked with other blocks that have and connectors. But it also has positive And connectors on the inside of two “holes” on the right side.
These connectors show that a stack of and-connected blocks is expected here. These are “internal” and connectors. A block usually won’t work properly if it has any internal And connectors that are left empty.
An external And connector with nothing attached to it doesn’t do anything, and you don’t have to connect anything to it.
You also don’t need to worry about and connectors not fitting. All blocks with an and connector can connect to all other blocks with an and connector.
Keeping Connected: Outer Blocks
For your encoding to work, all of the blocks need to be connected to an outer block that has no empty connectors. The outer blocks are facts, rules, and queries, and look like this:
The Facts and Query blocks have only one And connector. The Rule query has two. All of them must be connected to a stack of blocks to work properly. And all blocks with connectors must be attached to (or attached to something that is attached to) an outer block with no empty connectors.
So if you have blocks hanging around with empty negative and connectors, that won’t work. But if you put them inside an outer block, it will.
What Fact, Rule, and Query blocks actually do is discussed here.
We say “blocks with connectors” must be attached to outer blocks, because there are some blocks that do not have connectors, and are allowed to stand alone in the workspace. An example is the “Include” block.
So you have well formed code if there are only full outer blocks, and blocks with no connections in the workspace.
Navigating the Blawx User Interface
The size of the workspace increases as necessary for however many blocks you add to it. If you can’t see all the blocks on the workspace, you can scroll around the workspace using the vertical and horizontal scroll bars.
You can also scroll the workspace by dragging any empty part of the workspace.
You drag blocks from the toolbox to the workspace in order to add them to your code, and you drag them around the workspace in order to connect them to one another.
Dragging a block in a vertical stack will drag that block and any blocks that are connected below it, but not blocks above it or blocks containing it.
Dragging a block will drag blocks contained in it.
Because of the different ways in which dragging behaves, it’s important to know which block is currently selected. For that reason, the currently selected block is highlighted with an orange boundary.
Block Context Menu
If you right-click on a block in the workspace you will get a context menu.
The Duplicate menu option will make a copy of the block you have selected (and any blocks that are contained in it, but not any blocks it is vertically stacked with), and put it on the workspace.
Adding a comment opens a bubble that you can type extra information into. That information has no effect on the meaning of the blocks, it is just to allow you to add more useful information to the workspace.
Comments are typically used by software developers to explain what a piece of code is supposed to do, and why it is built the way it is, so that if anyone else (or the same person, but after a long period of time) needs to make adjustments later, they can get up to speed more quickly.
That is a very good idea. When encoding legislation, until we add more specific features for it, the comments are also a good place to include information about the source for the rule.
When a block already has a comment, the context menu will allow you to delete it instead. When a block has a comment, that comment can be hidden or shown by clicking on the blue question mark icon that appears on the top left of the block.
Collapsing a block reduces it to one line high, and makes the right side of the block look “torn” to show that it is a collapsed block.
In a collapsed block the context menu will allow you to expand it to its normal size again.
Collapsing blocks can be very helpful when you are dealing with a lot of complicated outer blocks at the same time.
Note that when a block is collapsed you cannot see whether it has a comment.
A disabled block will change in colour to a cross-hatch pattern. Disabled blocks remain on the workspace, but they do not mean anything. So it does not matter whether a disabled block has unfilled connectors.
Disabling a block disables that block and any blocks it contains.
For a disabled block, the context menu will allow you to enable it again.
Deleting a block removes a block and any blocks it contains from the workspace. If you delete a block in a vertical stack, the blocks above and below will become vertically connected with each other.
The context menu will tell you how many blocks you are about to delete, as shown here:
If there is a help page for the specific kind of block you are using, the Help item in the context menu will take you to that help page. If there isn’t, it will be disabled.
The help context menu is also the only item that is available when you right click on a block in the toolbox.
Workspace Context Menu
There is also a context menu that you can access by right-clicking on an empty part of the workspace.
Undo and Redo
If you make a mistake, you can use the Undo and Redo commands in the workspace context menu to get things back to how they were before the mistake.
Clean Up Blocks
Cleaning up blocks will cause all the blocks in the workspace to be organized in a single vertical column along the left side of the workspace. This can be useful if your workspace has gotten out of control.
Collapse and Expand Blocks
Collapsing and expanding blocks from the workspace context menu does it to all the blocks in the workspace.
Deleting blocks from the workspace context menu will delete all the blocks in the workspace, and has the same effect as using the Menu, Clear Workspace command.
CTRL-C will copy the currently selected block and any blocks that would move with it if you dragged it.
CTRL-V will pase the most recently copied blocks slightly below and to the right of where it was copied (which may not be where you are looking).
Delete key will delete the currently selected block and any blocks it contains.
CTRL-Z will undo the most recent change to the workspace.
The trash can is located in the bottom right of the workspace, no matter where you scroll.
Dragging a block to the trash can deletes it from the workspace.
Clicking on the trash can will open the trash can and allow you to drag blocks that were deleted back into the workspace.
The Toolbox Menu
Commands that you can run on an entire workspace are located in the “Menu” section of the Toolbox.
The Clear Workspace command will delete all of the blocks in the current workspace.
The Load Workspace command will let you choose a local .blawx file to open as the current workspace. If you load a workspace with unsaved changes to the current workspace, those changes will be lost.
The Save Workspace command will allow you to save the current workspace to a local .blawx file.
Run Blawx Code
The Run Blawx Code command sends the current workspace to the Blawx reasoner and displays the results in the reasoner output area.
The Help command brings you to the Support section of Blawx.com.