Operators Blocks

"Green Blocks" redirects here. For the teal blocks, see Pen Blocks.

Operators blocks is one of the ten categories of Scratch blocks. They are color-coded light-green, and are used to script math equations and string handling. It was previously titled Numbers Blocks, but was renamed in Scratch 1.4 due to new blocks that handled strings.

There are currently 17 Operators blocks: 6 Boolean blocks and 11 Reporter blocks. This and PicoBoard Blocks are the only categories to contain no Stack blocks.

Blocks

Warning Note: Click on a block to learn more about it!

Scratch 2.0 has the following 6 Operators Boolean Blocks:

Scratch 2.0 has the following 11 Operator Reporter blocks:

Obsolete Blocks

Prior to Scratch 1.2, the () of () block was two separate blocks, Abs () and Sqrt (), with no other mathematical functions.

Suggestions

Scratchers have suggested an Operators block that solves exponents.[1][2]

(() ^ ():: operators)

Some Scratchers have suggested true and false Booleans, however this has not been implemented, possibly due to the easy workaround. [3] Here is a sample of what such blocks might look like:

<true::operators>
<false::operators>

Scratchers have also suggested a boolean block that checks to see if a string contains a word. However, this can easily be worked around. The suggested block would appear as:

[] contains []::operators

The workaround appears as follows:

define does [string] contain [word]?
set [letter# v] to (1) 
delete (all v) of [words v] 
add [] to [words v] 
repeat (length of (string)) 
if <(letter (letter#) of (string)) = [ ]> then
add [] to [words v] 
else
replace item (last v) of [words v] with (join (item (last v) of [words v]) (letter (letter#) of (string)))
end
change [letter# v] by (1)
end
if <[words v] contains (word)> then
set [contains? v] to [true]
else
set [contains? v] to [false]
end

References

  1. http://scratch.mit.edu/discuss/topic/9907
  2. https://scratch.mit.edu/discuss/topic/107714/
  3. https://scratch.mit.edu/discuss/topic/150228/?page=1
  • This page was last modified on 25 January 2017, at 03:46.