Published on *LEARN.PARALLAX.COM* (http://learn.parallax.com)

Compatible with all Propeller board types (except Scribbler Robot)

BlocklyProp has two categories of operators: numbers that work with numerical values, and strings that work with text characters.

Compatible with all Propeller board types (except Scribbler Robot).

The **NUMBER **operator blocks can accept **number value **blocks, and any other operation blocks or sensor blocks that provide a numerical value.

The **math operation **block performs a mathematical operation on the inserted value blocks. Non-integer (fraction or decimal) results will be truncated to an integer. Choose an operation from the drop-down menu:

- + addition
- - subtraction
- × multiplication
- ÷ division
- % modulus (remainder after division)
- ^ (raise to the power of)

The **math operation** block has two terms by default. Click the gear and drag over additional terms as needed. THE LIMIT IS 26 TERMS.

**Order of operations**

- Innermost, when operation blocks are nested
- Raising to a power - use nested operations to raise a power to a power or you may get unexpected results. Switch to the code view to verify that the operations performed on the terms are what you expect.
- Multiplication & division
- Addition & subtraction

To change the order of operations, nest operation blocks inside each other, and/or use the **Parentheses **block (below).

The **limit **block allows you to compare the inserted values, and use the highest or lowest value as chosen in the dropdown menu.

The **constrain **block prevents a value from being too large or too small before using it. Insert a value or variable item, and then enter the maximum and minimum values for the range you want that value to stay within before it is used.

The **de/increment **block increases (increment) or decreases (decrement) the variable attached to it by 1.

The **random **block provides a random number between the first inserted low value and the second inserted high value. The first number must be smaller than the second number. If they are not in that order, the resulting random value may be unexpected, such as a number outside the range specified.

The **bitwise **block performs a bitwise operation (& AND, | OR, ^ XOR, >> right shift, << left shift) on the two values inserted.

The **boolean comparison** block performs a boolean comparison between the two inserted values and provides a 1/true or 0/false depending on the option selected (and, or, and not, or not).

The **not **block performs the selected operation on the value attached and provides the result. The options are:

- not: provide the boolean (1/true or 0/false) opposite of the value attached to it. (Any number other than 0 provides a 0/false.)
- negate: provide the signed value complement; for example, negate 9 provides -9).
- abs: provide the absolute value; for example, absolute 9 and absolute -9 both provide 9.)

The **parentheses **block surrounds the enclosed block(s) with parentheses. Use parentheses to change the order of operations in a series of blocks.

The **compare values** block compares two inserted values and provides a boolean value, 1 if the equation is true, and 0 if it is false. Choose the type of comparison from the drop-down menu:

- = equal to
- ≠ not equal to
- > greater than
- < less than
- ≥ greater than or equal to
- ≤ less than or equal to

The **map value** block scales and offsets the inserted value from the first defined range to the second defined range. This block **does not** constrain the value that you've entered. For example, given the ranges as shown in the block above, if the value you enter is -5, it will output -10, because the block is asking the new range to be twice the original range.

The** advanced math **block performs a trigonometric, exponential, or logarithmic function on the inserted values, and stores the result in a variable. Angles are in integer degrees, not radians. Options are:

- the cosine
- the sine
- the tangent
- the square root
- e raised to the power
- the logarithm (base 10)
- the natural logarithm)

Since Blockly is working only with integer math, the block requires you to begin with a multiplier (the first inserted value). Although you could use 1 here, larger numbers make this block more precise.

The** inverse trig** block performs an inverse trigonometric function. The angles that this block calculates and stores are in integer degrees, not radians. Options are:

- arcsine
- arccosine
- arctangent

Because inverse trigonometry operations usually are done on ratios (one number divided by another, the block requires you to input both the numerator and denominator of the ratio. If you need the inverse trig operation of a single number, use 1 as the denominator (the second number).

Compatible with all Propeller board types (except Scribbler Robot)

Several string operator blocks have older versions that have been depricated, and if your project contains any of these older blocks, they will appear orange in color. While they will still work, it is a good idea to replace those blocks with newer versions and adjust your code accordingly. Most of the depricated blocks were depricated because they treated strings of text as one-referenced entities (One-referencing is where the first character of a string of text would be counted as character number 1. Zero-referencing is where the first character would be counted as character zero). While one-referecing is easier to understand, it wasn't fully compatible with other blocks and code since C is a zero-referenced language. Never versions of those blocks are all zero-referenced.

The **string variable set size** block is used to increase or decrease the size of the variable that can hold strings of text. By default, string variables are set to hold up to 64 characters. By decreasing the size of your string variables, you can save memory. By increasing the size of your string variables, you can hold longer strings of text.

Use the gear icon to add additional variables to the list, and set the size of each variable accordingly. If you've defined a constant using the **constant define** block, you can set the size of your variable to that defined constant when you click on the gear icon.

The **compare strings **block provides a value of 1 if the comparison between two strings is true, and 0 if the comparison is false. The drop-down menu selection determines the type of comparison:

- the same as
- not the same as
- alphabetically before
- alphabetically after

The alphabetical comparisons are only alphabetical if the case matches - a capital “A” sorts differently than a lowercase “a”.

The **length of string** block provides the number of characters in the string, or variable containing a string, inserted into the block.

The **combine strings** block combines the first and second string and stores them in the variable selected in the drop-down menu. The block uses a buffer, so it is safe to use this block to add text to the beginning or end of a string already stored in a variable.

The **find string location **block provides the position of a substring within a larger string. The block gives a number value representing where the starting location of the substring is in the larger string. For example, if you use this block to find the substring “World” in the string “Hello World!”, the block would return 7 because “World” starts at the 7th character in the string.

The **get character** at position block provides the ASCII character [1] (a number value between 0 and 255) for the character found in the string specified in the drop-down menu at the position set by the number value block.

The **set character** at position block sets the ASCII character [1] (a number value between 0 and 255) for the character in the string specified in the drop-down menu at the position set by the number value block.

The **get part of string** block stores the part of the string specified by the first drop-down menu from the start and end positions set by the number value blocks and stores it in the variable specified by the second drop-down menu.

The **split string** block is used to split up a string separated by the defined character. Can be used more than once to extract multiple string parts.

The **trim string** block removes extra spaces at the beginning and end of a string of text.

The **string empty** block is used to test if a string is null or empty.

The **create string** block is used for making a new string from attached values or text.

Use the gear icon to add additional values such as decimal, hexadecimal, or binary integers, ASCII characters, floating point numbers, or strings of text to the string.

The **scan string** block is used to look for and extract values or characters from a string. Use the gear icon to add types of values to search for and extract from the string such as decimal, hexadecimal, or binary integers, ASCII characters, or floating point numbers.

The **string to number** block converts the inserted string from decimal, hexadecimal, or binary format into an integer number, then stores the number in the chosen item.

This block has been deprecated. Its functionality is now in the **scan string** block.

The **number to string** block converts the inserted integer value into a string in decimal, hexadecimal, or binary format, and then stores the string in the chosen item.

This block has been deprecated. Its functionality is now in the **create string** block.

**Links**

[1] http://www.asciitable.com