Vtech Power Zone Plus Desktop User Manual - Page 34

to square :n, repeat 4 [forward :n right 90]

Page 34 highlights

Routines Additional commands can be created by defining new Logo routines. For example, here is a Logo routine to tell your PC how to make a square: The title "to square" - should be indented way as well as the final line "end". The command lines should be single-spaced. Also if possible we would like all the examples to appear in fixed pitch font Example: to square forward 10 right 90 forward 10 right 90 forward 10 right 90 forward 10 right 90 end Drawing a square consists of going forward and turning right four times. This can be written more concisely using a repeat command: to square repeat 4 [forward 10 right 90] end The repeat command has two sets of additional information or input - a number indicating the number of times to repeat the command ("4") and the list of commands to be repeated "[forward 10 right 90]". Once this routine is defined, one need only to write "square" and Logo will draw a 10-step square at the current Turtle location. This routine can draw squares of only one size. To enable it to draw squares of varying sizes, define the command with an input: to square :n repeat 4 [forward :n right 90] end This command contains additional information or input ":n" which indicates the variable size of the square. Once this routine is defined, one can write "square 5" to have Logo draw a 5-step square at the current Turtle location. "square 10" will Logo draw a 10-step square, "square 15" will Logo draw a 15-step square, and so on. A routine to draw an equilateral triangle is as follows: to triangle :n 26

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54

26
Routines
Additional commands can be created by defining new Logo routines. For example,
here is a Logo routine to tell your PC how to make a square:
The title “to square” – should be indented way as well as the final line “end”.
The command lines should be single-spaced. Also if possible we would like all
the examples to appear in fixed pitch font Example:
to square
forward 10
right 90
forward 10
right 90
forward 10
right 90
forward 10
right 90
end
Drawing a square consists of going forward and turning right four times. This
can be written more concisely using a repeat command:
to square
repeat 4 [forward 10 right 90]
end
The repeat command has two sets of additional information or input - a number
indicating the number of times to repeat the command (“4”) and the list of
commands to be repeated “[forward 10 right 90]”. Once this routine is defined,
one need only to write “square” and Logo will draw a 10-step square at the
current Turtle location.
This routine can draw squares of only one size. To enable it to draw squares of
varying sizes, define the command with an input:
to square :n
repeat 4 [forward :n right 90]
end
This command contains additional information or input “:n” which indicates the
variable size of the square. Once this routine is defined, one can write “square
5” to have Logo draw a 5-step square at the current Turtle location. “square 10”
will Logo draw a 10-step square, “square 15” will Logo draw a 15-step square,
and so on.
A routine to draw an equilateral triangle is as follows:
to triangle :n