1

Basic syntax

Scratch commands are specified using the text equivalent (see example below).

Find a detailed reference on our Docs page.

                                when flag clicked
move (10) steps
say (hello) for (2) seconds
                            
Black & white image of basic scratch code in English

Specifying values

Values are specified with round brackets, for example

                                set x to (100)
                            
Colored outline image of Scratch block in English

Conditions

Conditions are specified used angled brackets <> for example

                                if <mouse down> then
  change x by (10)
                            
Full colored image of Scratch condition in English

Drop down fields

Drop down fields are specified with square brackets [] regardless of whether they appear on the Scratch block with square or rounded corners. The image will have the correct corners depending on the block, for example.

                                go to [random position]
                            
Black & white image of Scratch block showing a dropdown field in English

Indentation

When indenting use either two spaces or a tab for each level of indentation. It is important to be consistent with your indentation otherwise it will create issues when the code is being parsed.

This code uses two spaces for each level of indentation

                                repeat (4)
  move (10) steps
  if <key [space] pressed> then
    turn right (90) degrees
                            
Black & white image of a Scratch C-block in English

Reporter blocks

Reporter blocks are specified by placing the name of the block in any value field.

For custom variables prefix them with the myvar! directive so that they will be displayed correctly.

                                y position
                            
Full colored images of a Scratch reporter block in English

Less than comparison

The Less than comparison is specified with "lt" instead of "<"

                                if <(y position) lt (-140)> then
  go to [random position]
                            
Colored outlined image of a Scratch script showing a less than condition in English

Greater than comparison

The greater than comparison is specified as "gt" and not ">"

                                repeat until <(x position) gt (100)>
  move (10) steps
                            
Full colored image of a Scratch script showing a greater than condition in English

Blocks with graphics

Scratch blocks with graphics are specified as shown in the code below. The text ":flag", ":right" and ":left" are automatically replaced with the the corresponding graphic.

                                when flag clicked
turn right (90) degrees
turn left (-20) degrees
                            
Black & white image of Scratch blocks that have icons in English

Specifying colors

When needing to specify colors simply state the Color, Saturation and Brightness values as shown in the code. Students can use the values to recreate the desired color.

                                if <touching color (c10 s20 b100)> then
  hide
                            
Full colored image of "touching color <>" block in English

Mystery directive

The Mystery directive is a great way to tests student's understanding of the material being taught.

Value fields, condition fields and entire blocks can be left blank by using the "mystery!" directive.

                                if <mystery! touching color (c10 s20 b100)> then
  hide
                            
Colored outlined image showing the result of the mystery directive in English