home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / MISC / TNH_PC.ZIP / FOULGER2.NL < prev    next >
Encoding:
Text File  |  1987-01-14  |  5.3 KB  |  174 lines

  1. Understanding LOGO
  2.  
  3.              Davis Foulger
  4.     Connecticut IBM PC User's Group
  5.  
  6. LOGO was developed explicitly as a
  7. children's teaching tool -- a
  8. language which would both introduce
  9. children to computers and provide a
  10. constructive environment in which
  11. they might learn by exploring. LOGO
  12. was designed as a language that would
  13. be easy to change and experiment
  14. with, and its development included
  15. testing with a lot of children.
  16. Effort was made to insure that
  17. children would have an easy time
  18. using the language.
  19.  
  20. One of the results of this effort is
  21. LOGO's turtle. The turtle is a
  22. metaphor that directly reflects
  23. LOGO's orientation to children.
  24. Turtles are real, and that reality
  25. helps children identify with the
  26. language, which associates screen
  27. movement with the movement of the
  28. turtle. It also makes it fairly easy
  29. to teach the basics of the language
  30. to children that don't have access to
  31. computers. Indeed, beginners are
  32. frequently taught the basics with toy
  33. turtles, or making believe that they
  34. are turtles.
  35.  
  36. Use of the turtle to take action
  37. (draw) on the computer forces the
  38. user to answer some fairly
  39. straightforward questions. These
  40. include:
  41.  
  42. o   Can I put the turtle somewhere?
  43.     LOGO responds to this question
  44.     with commands that include SETPOS
  45.     X,Y, which puts the turtle on a
  46.     point on the screen defined by X
  47.     and Y; and HOME, which puts the
  48.     turtle in the center of the
  49.     screen.  SETPOS 180,100 has the
  50.     same effect as HOME.
  51.  
  52. o   Can I point the turtle in the
  53.     direction I want it to go? LOGO
  54.     responds to this question with
  55.     commands that include SETHEADING
  56.     D, which points the turtle in a
  57.     compass direction where D is one
  58.     of the 360 degrees on a compass
  59.     (0 and 360 degrees are up on the
  60.     screen); and TOWARDS X,Y, which
  61.     points the turtle toward the
  62.     point on the screen defined by X
  63.     and Y.  Note that both of these
  64.     commands specify an absolute
  65.     direction.
  66.  
  67. o   Can I move the turtle around?
  68.     LOGO responds to this question
  69.     with its FORWARD X and BACK X
  70.     commands, which instruct a turtle
  71.     to take X number of steps either
  72.     FORWARD or BACK.
  73.  
  74. o   Can I make the turtle turn? LOGO
  75.     responds with commands that let
  76.     the turtle turn a given number of
  77.     degrees (out of 360 degrees) to
  78.     the right or left.  LEFT 180 and
  79.     RIGHT 180 both tell the turtle to
  80.     turn around. LEFT 90 tells it to
  81.     turn sideways to the left. Note
  82.     that these commands specify a
  83.     direction relative to the
  84.     direction the turtle is pointing
  85.     in.
  86.  
  87. o   Can I see where the turtle has
  88.     been? The answer to this question
  89.     is yes, but you don't have to see
  90.     its trace. Indeed, you can even
  91.     cover your tracks. The PENDOWN
  92.     command tells the turtle to draw
  93.     a line wherever it goes (the
  94.     result, as you might imagine, is
  95.     a drawing). The PENUP command
  96.     tells it not to draw when it
  97.     moves (the result is more
  98.     complicated drawings. The
  99.     PENERASE tells it to draw, but to
  100.     use the same color as the paper
  101.     (screen). The result of PENERASE
  102.     can be disappearing lines.
  103.  
  104. These eleven commands are all you
  105. need to make some pretty fancy
  106. drawings in LOGO, and they are fairly
  107. easy to remember. Children tend to
  108. learn them quickly.  Interestingly,
  109. adults do too.
  110.  
  111. It should be noted that these "turtle
  112. graphics" have been widely emulated.
  113. They've shown up in a number of
  114. programming languages and have even
  115. been implemented as primitives to an
  116. operating system. It is, in fact,
  117. fairly simple to implement turtle
  118. graphics in DOS 2.0 BASIC.
  119.  
  120. With these eleven commands, it is
  121. fairly easy to use LOGO as a kind of
  122. calculator for drawings. You put the
  123. turtle somewhere on the screen and
  124. just enter commands, one at a time,
  125. until the drawing is finished. There
  126. is nothing wrong with taking this
  127. approach. Indeed, the fact that you
  128. can do it is one of LOGO's better
  129. features. Still, with the addition of
  130. one more command, we can extend the
  131. range of LOGO considerably.
  132.  
  133. The TO xxxx END command is a command
  134. that lets you write your own commands
  135. in LOGO. If, for instance, you find
  136. yourself drawing a lot of squares in
  137. LOGO, the TO xxx END command allows
  138. you to define a SQUARE command that
  139. will draw squares for you. As an
  140. example:
  141.  
  142.  TO SQUARE
  143.   FORWARD 10 LEFT 90
  144.   FORWARD 10 LEFT 90
  145.   FORWARD 10 LEFT 90
  146.   FORWARD 10 LEFT 90
  147.  END
  148.  
  149. This sequence of commands in LOGO
  150. creates a command, called SQUARE,
  151. that draws squares that are 10 units
  152. long on each side. The sequence is
  153. really fairly simple, enclosing the
  154. commands that you would write to draw
  155. a square between the TO and END. Note
  156. that we really do the same thing four
  157. times. Writing a command that draws
  158. squares could save us a lot of
  159. typing.
  160.  
  161. In some sense, the TO xxx END command
  162. allows you to teach your "turtle" how
  163. TO do something. LOGO's choice of
  164. commands here is typical of the
  165. language, which seems to always
  166. prefer highly descriptive and natural
  167. words.  Note also that the result of
  168. building this command is really a
  169. mini program. In some sense, LOGO
  170. teaches you how to program without
  171. ever really making you write "a
  172. program". All you really do is build
  173. new commands out old ones.
  174.