12Blocks
Welcome | Contents | Getting Started | Reference | Hardware | FAQ | Buy
Blog | Forum
Overview | Editor Interface | Editor Dialogs | Advanced | Language | Blocks

Parts of a Program

Parts of a Program

·           Start Blocks (indicated by triangular tops) are used to start a stack of blocks. 
·           Blocks have some effect- they do something.  Most can be customized by their yellow parameter areas.  Some have multiple attachment tabs.
·           Loop blocks repeatedly execute their stack
·           Conditional blocks execute their stack if a condition is met 
·           Expressions can be typed into a parameter area.  An expression can include text and other blocks.  Expressions can include variables and arrays.  Expressions are evaluated in a specific order.  Expressions can be Boolean or produce a value.
·           Variables can be global to the entire program.  Variables can be part of the argument list of a function.  Variables can be local to a function.  Edit global variables in the “vars” section.
·           Arrays are global and can be used for strings- edit them in the “vars” section.
·           Functions are defined using a “Function Start” block.  You need to specify the function’s name, arguments and local variables in the start block.  You can use a return block to return a value.  The function section of the library will contain a block to call your function once you’ve named it.  Changing the name or arguments of your function’s start block will change all blocks that call that function.  You can call a function from itself- this is recursion.
·           You can wait for events to trigger a series of blocks with the "when <x>" block.
·           You can start named tasks both synchronously and asynchronously with the "start task" f and "start task and wait" blocks.  Use the “start task” block to start an asynchronous event- the code in the handler will run in parallel.  Use the “start task and wait” block to start a synchronous event- the code in the handler will run and finish before your code resumes.

Interface Blocks

Interface blocks are special blocks that present information on the worksheet

To use them, drag them onto the worksheet.  Blocks that don't have tabs don't need to be connected to other blocks and can be resized with the bottom right corner.  Click on the yellow regions to customize them.  Here are some commonly used blocks, for more info see block reference:
  
Program Info manages the title of the worksheet for use when uploading to the community.  You can also edit variable and array definitions and which files are imported. It's good practice to include a program info block in your programs.
graphic
Values shows you the value of global variables. Click on the yellow area showing the variable value to change it.
graphic
Pins shows the IO state of the device's IO pins. Red indicates the pin is currently “high”, blue indicates it’s “low”, or 0V.
Logic indicates activity for pins used by your program versus time at selectable time scales.
graphic
Terminal shows a terminal view that shows the output of your program when using the terminal blocks.  Entering text into the text area will send the keystrokes to the device where they can be read in with the terminal input blocks.
graphic
Graph displays a real-time graph of variable values graphed against configurable time scales. 
graphic
Background displays a configurable image or color.  Blocks can attach to a background.
Switch can be toggled to set a variable's value to 1 or 0. 
Meter indicates a variable's value as a line
Textbox shows the variable's value and can be clicked to change it
Joystick is used to change 2 variable values
graphic