Action Commands
Action block under variable palette (as shown below) can be used to define actions.

We have two actions blocks and both the blocks are used for defining the action to the turtle.The first action block with the triangular top is used to define the action and the second is use to execute the named action stack.

Defining action:
Action has to be defined with the name that will be attached as shown below.

Here we are giving the name square to our action command .Then we define the actions which are to be executed by this action . Here , the stacks defining the action ‘square' is attached as shown below.

In the above action 'square', the turtle moves forward 100 spaces then turns right 90 degrees(the command repeats 4 times).
Executing action:
The action 'square' can be called using the second action block.

Here, the action 'square' has to be executed followed by the turtle turning right 45 degrees and the complete set has to be repeated 8 times.

Now, when the above program is executed the output will be displayed as given below

Action block under variable palette (as shown below) can be used to define actions.
We have two actions blocks and both the blocks are used for defining the action to the turtle.The first action block with the triangular top is used to define the action and the second is use to execute the named action stack.
Defining action:
Action has to be defined with the name that will be attached as shown below.
Here we are giving the name square to our action command .Then we define the actions which are to be executed by this action . Here , the stacks defining the action ‘square' is attached as shown below.
In the above action 'square', the turtle moves forward 100 spaces then turns right 90 degrees(the command repeats 4 times).
Executing action:
The action 'square' can be called using the second action block.
Here, the action 'square' has to be executed followed by the turtle turning right 45 degrees and the complete set has to be repeated 8 times.
Now, when the above program is executed the output will be displayed as given below
No comments:
Post a Comment