Command – Codeblocks
Working with code blocks is pretty intuitive, but let's take a look at some of the general commands we should be aware of First, let's examine how we delete blocks.
There are three primary ways in which we can delete a block.
The first is to drag a block to the waste receptacle icon in the lower right of the canvas.
Dropping the block adds it to the delete receptacle, and the icon changes slightly, showing the receptacle lid ajar to let you know it is no longer empty.
Clicking on the receptacle icon opens it and reveals the contents showing the blocks you've deleted.
You can select a deleted block and drag it into the canvas to reuse it.
Note that the block still remains in the deleted blocks receptacle though.
The second way to delete a block is to drag and drop it on the block categories pane to the left.
Clicking on the receptacle icon again opens it and reveals the contents showing that blocks dropped on the left pane are collected in the receptacle also.
A third way to delete blocks and add them to the deleted blocks receptacle is to simply select them and then press the delete key on your keyboard.
The deleted blocks waste receptacle is automatically emptied when we exit the product definitions.
Another common set of tools to know about are those we use to duplicate and reuse blocks.
Here, a block is defined and then duplicated using the duplicate option on the right click contextual menu. The new block is updated In this case, to define it as a maximum input block for a length parameter, and then the right click duplicate connected option is used to create copies of the pair of connected blocks.
Another way to duplicate blocks is to simply select the block and then press control c on the keyboard to copy, and then control v on the keyboard to paste.
An additional way to reuse blocks is called the backpack.
The backpack allows you to save blocks and connected blocks for reuse later.
The backpack also allows you to transport blocks between product definitions.
Here we add connected code blocks to the backpack by dragging and dropping on the backpack icon.
This adds the block to the pack, but does not remove it from the canvas.
Clicking on the backpack icon shows the contents of the pack.
The blocks can be selected from the backpack pane and dragged into the canvas.
Here, the new blocks are updated to use a different parameter, making it quick and easy to recreate the original block functionality for the parameter.
This new set of blocks is added to the backpack as well.
Now we'll click the save button and this will save the backpack contents to the product definition.
Next, we'll switch to a new product definition and reuse the same block in that definition.
Looking in the backpack, we find the blocks there waiting for us, ready for them to be used in this product definition also.
Another feature to know about is the ability to collapse code blocks by selecting them and choosing the collapse option from the context menu.
This can help make space in the canvas as you edit.
To reverse this, select the collapsed block and choose the expand option from the context menu.
You can also right click in the canvas and choose to collapse all blocks.
To expand all collapsed blocks, right click in the canvas and choose expand blocks.
Here, two sets of blocks are stacked one above the other.
Logically, the blocks are red and run from top to bottom.
What happens though if the blocks are arranged next to each other?
The answer is the blocks are read from top down and then left to right.
Dragging and dropping blocks in the canvas is simple and easy as long as we know how to handle them.
When grabbing a block to move, if we select the bottom block, it will tear away from the connected blocks.
Selecting the top block in a block set will move the entire set of connected blocks.
Snaping a block to another can be done by snapping to the top or the bottom.
Selecting a block in the middle of a set of connected blocks will tear away that block and all blocks connected below it.
Another useful feature to know about is the ability to add comments to the blocks by right clicking on a block and choosing add comment.
Upon doing so, a comment symbol is added to the block. And if we click it, we can type in the comment text.
Clicking the symbol again hides the comment.
Finally, the ability to disable a block is handy also.
To do so, select the block and then choose disable block from the context menu.
To enable it again, You guessed it. Select the block and then choose enable block.
In summary, there are three ways to delete blocks. Using the delete block's waste receptacle icon, using the left hand pane and using the delete key on the keyboard.
Reusing blocks can be done within the current product definition by using the right click duplicate options, or control c and control v on the keyboard.
Reuse blocks between product definitions by using the backpack tool.