home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / DRI-archive / roche / DrLogo_Ref_Sec1_5.txt < prev    next >
Text File  |  2009-12-11  |  85KB  |  2,152 lines

  1. DRLRM1.WS4      (= "Dr. Logo Reference Manual", Section 1)
  2. ----------
  3.  
  4. (Retyped by Emmanuel ROCHE. Posted to comp.os.cpm.amethyst by
  5. Roche on 18 Apr 2005.)
  6.  
  7.  
  8. Section 1: Components of Dr. Logo
  9. ---------------------------------
  10.  
  11. A procedure is an action that Dr. Logo can do. A Logo program is
  12. made  up of procedures. You will probably start by writing  one-
  13. procedure programs, but you will build your first procedures out
  14. of  procedures  that  come  with  Dr.  Logo,  called  "Dr.  Logo
  15. primitives".  Later, you will use the procedures that  you  have
  16. written,  as  well  as Dr. Logo  primitives,  to  build  complex
  17. programs.   Procedures  are  the  basic  building   blocks   for
  18. programming with Dr. Logo.
  19.  
  20. A  procedure  is made up of expressions. An expression  has  two
  21. parts: a procedure name and inputs to the procedure. That is why
  22. you  need Dr. Logo primitives to build your first procedure.  To
  23. Dr.  Logo, everything you type is either a procedure name or  an
  24. input to a procedure.
  25.  
  26. Although you can build a procedure out of many expressions,  you
  27. can  also ask Dr. Logo to evaluate expressions one at a time  by
  28. entering  them individually to the ? prompt, which is  sometimes
  29. called the interpreter or toplevel. For example,
  30.  
  31.         ?print "Salutations!
  32.         Salutations!
  33.  
  34. In  this  example,  print "Salutations! is  an  expression.  The
  35. procedure name "print" identifies a Logo primitive that displays
  36. its  input, Salutations!, on the screen. As in all  examples  in
  37. this  book, the line following "?" shows what the user types  at
  38. the keyboard. After you type a line at toplevel, you must  press
  39. the  Enter  key,  <--+,  to tell Dr.  Logo  that  you  want  the
  40. expressions on the line evaluated.
  41.  
  42. A  procedure  can require a certain number and kind  of  inputs.
  43. Input  to  a  procedure can be words, numbers,  or  lists.  This
  44. section formally defines how to put characters together to  form
  45. procedure  names,  words, numbers, and lists, so  that  you  can
  46. combine  them into expressions. Then, it tells you how Dr.  Logo
  47. evaluates a line when you put more than one expression on it.
  48.  
  49.  
  50. 1.1 Dr. Logo character set
  51. --------------------------
  52.  
  53. To  build  a  procedure name or word, you  can  use  almost  any
  54. character  on  your  keyboard, including  upper-  and  lowercase
  55. letters, numerals, and symbols. For example
  56.  
  57.         box1
  58.         box2
  59.         RobinNest
  60.         draw&go
  61.  
  62. However,  Logo gives special meaning to certain characters.  For
  63. example,  blank spaces delimit words or numbers; a  blank  space
  64. before and a blank space after a word set the word off from  the
  65. rest of the line. The following special characters are also Logo
  66. delimiters:
  67.  
  68. Table 1-1. Dr. Logo special characters
  69.  
  70. Character     Type      Action/use
  71. ---------  ----------   ----------
  72.     [                   Begins a list
  73.     ]                   Ends a list
  74.     (                   Begins a grouped expression
  75.     )                   Ends a grouped expression
  76.     ;                   Begins comments
  77.     =       logical     Equal infix operation, outputs TRUE or FALSE
  78.     <       logical     Less-than infix operation, outputs TRUE or FALSE
  79.     >       logical     Greater-than infix operation, outputs TRUE or FALSE
  80.     +      arithmetic   Addition prefix operation,
  81.                           outputs sum of inputs.
  82.     -      arithmetic   Subtraction infix operation,
  83.                           outputs difference of two inputs.
  84.     *      arithmetic   Multiplication infix operation,
  85.                           outputs product of inputs.
  86.     /      arithmetic   Division infix operation,
  87.                           outputs quotient of inputs.
  88.     ^      arithmetic   Exponent infix operation,
  89.                           outputs first input number raised to
  90.                           the second input power.
  91.  
  92. When  you use a delimiter in an expression, you do not  need  to
  93. precede it with a blank to set it off from the rest of the line.
  94. Whenever one of these characters appears, Dr. Logo assumes  that
  95. it  starts a new word or number separate from anything  else  on
  96. the line. This simplifies typing expressions in many cases, such
  97. as
  98.  
  99.         256+1026
  100.  
  101. but complicates using these characters in situations other  than
  102. those  that Dr. Logo expects. For example, if you try to  use  a
  103. dash  as a hyphen (instead of a minus sign), you might  see  Dr.
  104. Logo add unwanted spaces:
  105.  
  106.         ?print [high-resolution turtle graphics]
  107.         high - resolution turtle graphics
  108.  
  109. To tell Logo that you want it to treat a delimiter as a part  of
  110. a  word,  precede the special character with a  backslash  ("\")
  111. called  "the quoting character" by Dr. Logo, which generates  it
  112. when you type Ctrl-Q.
  113.  
  114.         ?print [high\-resolution turtle graphics]
  115.         high-resolution turtle graphics
  116.  
  117. Dr.  Logo  recognizes other special characters  called  "control
  118. characters"   as  commands.  Control  characters  can   edit   a
  119. procedure,  interrupt  and  terminate a  procedure,  and  change
  120. between  full text, full graphics, and splitscreens. Section  3,
  121. "Editing  Commands", and Section 4, "Text and Graphic  Screens",
  122. describe Dr. Logo control characters.
  123.  
  124.  
  125. 1.2 Logo objects
  126. ----------------
  127.  
  128. A  Logo  procedure  can require a specific number  and  kind  of
  129. inputs  to  perform its task. The required input can be  one  or
  130. more words, lists, or numbers. When a procedure requires any one
  131. of  these,  we say that it can accept a "Logo  object",  meaning
  132. that  it  needs  a word, a list, or a  number  to  complete  its
  133. operation.  To  make  your procedures  more  flexible,  you  can
  134. represent  objects with names called "variables".  This  section
  135. describes words, lists, numbers, and variables.
  136.  
  137.  
  138. 1.2.1 Words
  139. -----------
  140.  
  141. A  Logo  word is a group of one or more  consecutive  characters
  142. separated  from  other characters on the line by  delimiters.  A
  143. blank  space  separates a word from the rest of  the  characters
  144. that  follow  it  on  the line. You can  use  periods  (".")  or
  145. underbars  ("_")  as connectors to make Dr. Logo  treat  several
  146. words as one word, as in the following example:
  147.  
  148.         ?print "choc.chip
  149.         choc.chip
  150.         ?print "oatmeal_raisin
  151.         oatmeal_raisin
  152.  
  153. In  English, a sentence is composed of words called "verbs"  and
  154. "nouns".  In  Logo, an expression is composed  of  words  called
  155. "procedure  names" and "inputs", which can be other  names.  Dr.
  156. Logo  needs  a way to distinguish an input name  (noun)  from  a
  157. procedure name (verb). So, when you type a Logo expression,  you
  158. must precede an input name with quotes ("). If you do not,  Logo
  159. complains. For example,
  160.  
  161.         ?print "hi_there
  162.         hi_there
  163.         ?print hi_there
  164.         I don't know how to hi_there
  165.  
  166. Although quotes have this special meaning at the beginning of  a
  167. word,  they  are  not a delimiter, and can be use  as  a  normal
  168. character within a word. Do not use quotes at the beginning of a
  169. word, except for this reason. Dr. Logo has a special  primitive,
  170. quote, that has the same effect as quotes.
  171.  
  172.         ?print quote hi_there
  173.         hi_there
  174.  
  175. Other  Dr.  Logo  primitives can examine  a  word  character  by
  176. character,  take  a word apart, and put a  word  together.  When
  177. manipulating  a  word  in  one of  these  ways,  Logo  treats  a
  178. character in a word as a one-letter word. For example,
  179.  
  180.         ?first "zebra
  181.         z
  182.         ?first first "zebra
  183.         z
  184.         ?first "z
  185.         z
  186.         ?butfirst "atypical
  187.         typical
  188.         ?last "rough
  189.         h
  190.         ?butlast "dates
  191.         date
  192.         ?word "R2 "D2
  193.         R2D2
  194.  
  195. As  mentioned in Section 1.1, "Dr. Logo character set", you  can
  196. tell  Dr. Logo that you want to use a delimiter character  in  a
  197. word by preceding the delimiter with a backslash ("\"). However,
  198. if a delimiter character is the first character in the word, and
  199. the  word  is preceded by quotes ("), in most cases you  do  not
  200. have  to  put a backslash between the quotes and  the  delimiter
  201. character.
  202.  
  203.         ?"+more
  204.         +more
  205.         ?ascii "*
  206.         43
  207.  
  208. However,  blank  spaces and square brackets ("["  and  "]")  are
  209. treated  as delimiters, even when preceded by quotes ("). Use  a
  210. backslash  ("\") after quotes (") to tell Logo to treat a  space
  211. or square brackets as a normal character.
  212.  
  213.         ?ascii "[
  214.         ascii doesn't like an empty word as input
  215.         ?ascii "\[
  216.         93
  217.  
  218. The Dr. Logo primitive "readquote" (or "rq") creates a word that
  219. contains all the characters in a line typed at the keyboard.  If
  220. the  line  contains  delimiters,  readquote  inserts   backslant
  221. characters in front of each one, to make the line one word.  You
  222. can use readquote to create a command line for a function key to
  223. recall;  fkey  requires  a  word as  input.  See  the  following
  224. example.
  225.  
  226.         ?fkey 2 rq
  227.         setd "b: resetd
  228.         ?setd "b: resetd <Ctrl-G> <Enter>
  229.  
  230.  
  231. 1.2.2 Lists
  232. -----------
  233.  
  234. A  literal list is a series of Logo objects enclosed  in  square
  235. brackets  ("["  and "]"). You can create a list  without  square
  236. brackets  by  using  the "list" or  "sentence"  primitive.  Each
  237. element  of  a list can be a word, a number,  or  another  list.
  238. Within  the  list,  objects are delimited from  one  another  by
  239. spaces.  Dr.  Logo treats every object in a literal  list  as  a
  240. literal  object, so you do not need to put quotes in front of  a
  241. word  included  within a literal list. The following  are  valid
  242. literal lists:
  243.  
  244.         [Salutations!]
  245.         [L M N]
  246.         [[bread butter] [soup sandwich] [cheese crackers]]
  247.         [10 20 [22 25] 30]
  248.  
  249. The  following  examples  show  how  to  create  a  list   using
  250. "sentence" and "list":
  251.  
  252.         ?list "L "M "N
  253.         [L M N]
  254.         ?sentence [I like] "hamburgers
  255.         [I like hamburgers]
  256.  
  257. The  same  Logo  primitives that manipulate  elements  of  words
  258. manipulate elements of lists.
  259.  
  260.         ?butfirst [not really]
  261.         [really]
  262.         ?butlast [not really]
  263.         [not]
  264.         ?fput 5 [10 20 [22 25] 30]
  265.         [5 10 20 [22 25] 30]
  266.  
  267. After  the fput expression is executed, the list above has  five
  268. elements,  the fourth of which is a list. The following  example
  269. shows how to count elements of lists within lists:
  270.  
  271.         ?count [5 10 20 [22 25] 30]
  272.         5
  273.         ?count item 4 [5 10 20 [22 25] 30]
  274.         2
  275.  
  276. The  following table compares the four primitives that can  take
  277. two objects as input and output a word or list.
  278.  
  279. Table 1-2. Comparison of list primitives
  280.  
  281. Primitive       Input 1         Input 2         Output
  282. ---------       -------         -------         ------
  283. list            "yellow         "green          [yellow green]
  284. sentence        "yellow         "green          [yellow green]
  285. fput            "yellow         "green          "yellowgreen
  286. lput            "yellow         "green          "greenyellow
  287.  
  288. list            "sky            [is blue]       [sky [is blue]]
  289. sentence        "sky            [is blue]       [sky is blue]
  290. fput            "sky            [is blue]       [sky is blue]
  291. lput            "sky            [is blue]       [is blue sky]
  292.  
  293. list            [say hello]     [to me]         [[say hello] [to me]]
  294. sentence        [say hello]     [to me]         [say hello to me]
  295. fput            [say hello]     [to me]         [[say hello] to me]
  296. lput            [say hello]     [to me]         [to me [say hello]]
  297.  
  298. list            [hello]         []              [[hello] []]
  299. sentence        [hello]         []              [hello]
  300. fput            [hello]         []              [[hello]]
  301. lput            [hello]         []              [[hello]]
  302.  
  303.  
  304. 1.2.3 Numbers
  305. -------------
  306.  
  307. A number is one or more numerals separated from other characters
  308. on the line by spaces or other delimiters. A number is a kind of
  309. word,  but  you  do not have to put quotes (")  in  front  of  a
  310. number,  unless you want to use it as a variable name. Dr.  Logo
  311. does  not  try to treat a word that starts with a numeral  as  a
  312. procedure  name.  In fact, Dr. Logo will not let  you  define  a
  313. procedure name that starts with a numeral.
  314.  
  315. A  number  can contain a + or - to indicate sign.  But,  because
  316. these special characters are delimiters and arithmetic operators
  317. as  well  as signs, you might accidentally combine  two  numbers
  318. into one expression. To prevent this, Dr. Logo interprets spaces
  319. and numbers combined with arithmetic operators as follows:
  320.  
  321.         5-2     is interpreted as 3.
  322.  
  323.         5 - 2   is also interpreted as 3. However,
  324.  
  325.         5 -2    is interpreted as two numbers: 5 and -2.
  326.  
  327. Dr.  Logo  uses  two  kinds of  numbers:  integers  and  decimal
  328. numbers. You can input negative or positive decimal numbers with
  329. up to 15 significant digits, and any integer between  2147483647
  330. and -2147483648.
  331.  
  332. Most  arithmetic  operations can accept either an integer  or  a
  333. decimal number as input. Some take integers as input, but output
  334. a decimal number.
  335.  
  336.         ?13 / 7
  337.         1.85714285714286
  338.  
  339. Dr.  Logo  supports primitives that convert decimal  numbers  to
  340. integers,  create  exponential and random numbers,  and  perform
  341. trigonometric  and logarithmic functions. Internally,  Dr.  Logo
  342. uses  both single- and double-precision integers  and  floating-
  343. point  numbers.  Dr.  Logo  always  uses  double-precision   for
  344. calculations,  but  converts  numbers  to  single-precision  for
  345. display   or  storage  when  accuracy  to  15  places   is   not
  346. compromised. Internally, numbers are stored in IEEE standard 64-
  347. bit  format, in the dynamic range 10 to the power of -308 to  10
  348. to the power of +308.
  349.  
  350. In  the world of mathematics, there are numbers that  cannot  be
  351. represented  by  numerals. Dr. Logo outputs special  words  that
  352. represent  these numbers: +INF represents the positive  infinite
  353. number,  -INF represents the negative infinite number,  and  NAN
  354. represents "not a number" for any mysterious entity that is  not
  355. a number at all.
  356.  
  357.         ?1/0
  358.         +INF
  359.         ?-1/0
  360.         -INF
  361.         ?0/0
  362.         NAN
  363.  
  364.  
  365. 1.2.4 Variables
  366. ---------------
  367.  
  368. A  variable  is  a  "container" that  holds  a  Logo  object.  A
  369. container  in  your kitchen labeled "Cookie Jar"  might  contain
  370. chocolate chip, peanut butter, some other kind of cookies, or no
  371. cookies  at all. In Dr. Logo, a variable can have any  name  you
  372. give  it, and contain any object -- word, number, or list.  Here
  373. is the simplest way to create a variable:
  374.  
  375.         ?make "favorites [choc.chip peanut.but !
  376.         oatmeal.raisin cream.fill brownie pinwh!
  377.         eel shortbread snickerdoodle]
  378.  
  379. After  the make expression is executed, the long list of  cookie
  380. types has a name: "favorites.
  381.  
  382. Referring  to  an object by a variable name lets  you  write  an
  383. expression that is independent of the object it manipulates. For
  384. example,  the  person  responsible for keeping  the  cookie  jar
  385. filled could enter:
  386.  
  387.         ?if emptyp :cookie.jar [make "cookie.ja!
  388.         r first shuffle :favorites]
  389.  
  390. which  means, if the cookie jar is empty, put the first kind  of
  391. cookie from the shuffled list of favorites into the cookie jar.
  392.  
  393. Because  Logo  programmers use variables  frequently,  they  use
  394. several terms to describe the relationship between a  variable's
  395. name and its contents. For example, if the make expression  puts
  396. snickerdoodle  in cookie.jar, a Logo programmer  might  describe
  397. the relationship in any or all of these ways:
  398.  
  399.         - cookie.jar is a variable, snickerdoodle is its value
  400.         - cookie.jar is the name of snickerdoodle
  401.         - cookie.jar contains snickerdoodle
  402.         - cookie.jar is bound to snickerdoodle
  403.  
  404.         - snickerdoodle is the "thing" of cookie.jar
  405.         - snickerdoodle is the contents of cookie.jar
  406.         - snickerdoodle is the value of cookie.jar
  407.  
  408. There are two ways to reference the contents of a variable:
  409.  
  410.         ?thing "cookie.jar
  411.         snickerdoodle
  412.         ?:cookie.jar
  413.         snickerdoodle
  414.  
  415. A  colon (":") before a variable name makes Dr.  Logo  reference
  416. the  contents of the variable, instead of treating the  variable
  417. name as a word.
  418.  
  419. No matter how you think of variables, remember that you can  use
  420. a  variable in an expression without being concerned  about  the
  421. variable's  actual value. Variables help you  write  expressions
  422. that  are  independent of the data they manipulate.  Section  2,
  423. "Working  with  Procedures", tells how to use  variables  within
  424. procedures.
  425.  
  426.  
  427. 1.3 Lines and expressions
  428. -------------------------
  429.  
  430. You  can  put as many expressions on a line as you wish,  but  a
  431. line at toplevel cannot contain more than 132 characters.
  432.  
  433. In  general, Dr. Logo evaluates expressions on a line from  left
  434. to right. It treats everything, including other expressions,  to
  435. the  right  of a primitive name or identifier as input  to  that
  436. primitive if the primitive requires an input.
  437.  
  438.         ?random 10 > 5
  439.         random doesn't like TRUE as input
  440.         ?5 > random 10
  441.         FALSE
  442.  
  443. However,  Dr. Logo does not evaluate arithmetic  expressions  in
  444. strict  left-to-right  order. It evaluates / and  *  expressions
  445. first,  from left to right, then goes back and evaluates + or  -
  446. expressions.
  447.  
  448.         ?2 * 3 + 7 / 5
  449.         7.4
  450.  
  451. To make Dr. Logo evaluate expressions in a different order,  you
  452. can  group  expressions in parentheses ["(" and ")"].  Dr.  Logo
  453. evaluates the expression in the innermost parentheses first. The
  454. order in which Dr. Logo evaluates your expression can make a big
  455. difference in the output!
  456.  
  457.         ?(random 10) > 5
  458.         FALSE
  459.         ?2*(3+7)/5
  460.         4
  461.  
  462.  
  463. EOF
  464. DRLRM2.WS4      (= "Dr. Logo Reference Manual", Section 2)
  465. ----------
  466.  
  467. (Retyped by Emmanuel ROCHE.)
  468.  
  469.  
  470. Section 2: Working with procedures
  471. ----------------------------------
  472.  
  473. This section discusses several aspects of working with Dr.  Logo
  474. procedures.  It tells how to construct a procedure and  give  it
  475. multiple  inputs. It also describes how Dr. Logo keeps track  of
  476. executing procedures.
  477.  
  478.  
  479. 2.1 Constructing procedures
  480. ---------------------------
  481.  
  482. The following sections describe how to put a procedure together:
  483. how  to  define it, how to make it readable, and how  to  use  a
  484. variable  to  pass  information between procedures  and  make  a
  485. procedure require an input.
  486.  
  487.  
  488. 2.1.1 Naming and defining procedures
  489. ------------------------------------
  490.  
  491. To  define a procedure is to teach Dr. Logo a new verb, that  is
  492. to  say, to tell Dr. Logo how to do a new thing. You  teach  Dr.
  493. Logo  a new verb by describing the new activity with  primitives
  494. and  other words Dr. Logo already know or will know  before  you
  495. execute  the procedure. For example, Dr. Logo  knows  primitives
  496. that  make the turtle go forward, repeat, and turn right.  Using
  497. these primitives, you can describe how to draw a square, and use
  498. that description to define a new procedure.
  499.  
  500. The  simplest way to define a new procedure is to begin  a  line
  501. with  the special word "to", which makes Dr. Logo  remember  the
  502. next word you type as a new procedure name. Your procedure  name
  503. should  tell  what your procedure does, and can start  with  any
  504. character,  except a numeral. Dr. Logo will complain if you  try
  505. to  use the name of a primitive as a procedure name, unless  you
  506. have  set the system variable REDEFP to TRUE. When you  start  a
  507. line with "to", Dr. Logo gives you a new prompt character, >, to
  508. tell  you it will not immediately execute the instructions  that
  509. you enter to define the new procedure.
  510.  
  511.         ?to square
  512.         >repeat 4 [forward 60 right 90]
  513.         >end
  514.         square defined
  515.         ?
  516.  
  517. The  special  word "end" tells Dr. Logo that you  have  finished
  518. defining  your procedure, and returns you to the ?  prompt.  You
  519. must enter "end" by itself as the last line of a procedure.  Now
  520. that  "square"  is defined, you can use square  as  a  procedure
  521. name,  as  follows. Also see Colorplate 23 at the  beginning  of
  522. Section 6, "References to Primitives".
  523.  
  524.         ?square
  525.  
  526. Logo  programmers  use  terms  similar to  those  they  use  for
  527. variables  to describe the relationship of a procedure  and  its
  528. definition. Here is how these terms apply to the procedure  just
  529. defined:
  530.  
  531.         - "to square" is the title line of square
  532.         - square is the name of [repeat 4 [forward 60 right 90]]
  533.         - [repeat 4 [forward 60 right 90]] is the definition of square
  534.         - [repeat 4 [forward 60 right 90]] is the body of square
  535.  
  536. The  body  of a procedure is a special kind of list: a  list  of
  537. expressions.  This list can contain as many expressions  as  you
  538. want,  or it can be an empty list. Because Dr. Logo  treats  the
  539. definition  of a procedure as a list, you can write a  procedure
  540. that  first combines expressions into a list, and  then  defines
  541. this list as the body of a new procedure. The description of the
  542. "define"  primitive  in Section 6, "References  to  Primitives",
  543. tells how one procedure can define another.
  544.  
  545. You  can  use  the  Dr.  Logo  screen  editor  to  modify   your
  546. procedures' definitions. When you use the editor, you can change
  547. the  body  of a procedure, add a new procedure,  or  change  the
  548. title  line of an existing procedure. When you exit the  editor,
  549. the  new  or  changed  procedures  are  defined,  replacing  any
  550. previous  definitions for those names. The descriptions  of  the
  551. ed,  edall, and edps primitives in Section 6 tells how  to  load
  552. procedures  into  the  Dr.  Logo  editor.  Section  3,  "Editing
  553. Commands", tells how to use the editor.
  554.  
  555.  
  556. 2.1.2 Writing readable procedures
  557. ---------------------------------
  558.  
  559. All  programmers  want to make their procedures as  readable  as
  560. possible. A readable procedure is a distinct advantage when  you
  561. try  to share your work with friends, or try to use a  procedure
  562. several months after writing it.
  563.  
  564. Two  traditional  tools that make a program readable  are  short
  565. procedures  and  long  names for procedures  and  variables.  In
  566. general,  short  procedures are more readable  than  long  ones.
  567. Short  procedures  are easier to understand, test,  and  combine
  568. with  other  procedures. Long procedure and variable  names  can
  569. help  describe  the purpose and function of procedures,  or  the
  570. kind of data represented by variables. However, long names  take
  571. up  valuable  memory space, so you might have  to  shorten  your
  572. names  if  you  write  a  large  program  that  needs  all  your
  573. workspace.
  574.  
  575. Dr. Logo gives you special help in writing readable  procedures.
  576. For  example, Dr. Logo lets you break long expressions into  two
  577. or  more  lines. Generally, a line in a procedure  is  a  single
  578. expression:  a  procedure  name and its  inputs.  However,  some
  579. procedures need complex inputs, such as lists of instructions or
  580. predicate  expressions. This kind of line can grow so long  that
  581. it becomes difficult to read. For example, an "if" command  with
  582. a  long  predicate  expression and two  instructions  lists  can
  583. easily exceed the width of your display. When this happens,  Dr.
  584. Logo  prints  an  exclamation  point  ("!")  and  displays   the
  585. remainder of the command on the next line.
  586.  
  587.         ?to check.for.favorites
  588.         >if memberp :cookie.jar :favorites (pr !
  589.         [edible cookies available] (pr [forget !
  590.         it!])
  591.         >end
  592.         check.for.favorites defined
  593.  
  594. You  can  clean up your procedure's appearance by  breaking  the
  595. long  expression into several lines. If you press the Enter  key
  596. and  begin the next line with a space or a tab, Dr. Logo  treats
  597. the new line as a continuation of the expression on the previous
  598. line.
  599.  
  600.         ?to check.for.favorites
  601.         >if memberp :cookie.jar :favorites
  602.            [pr [edible cookies available]]
  603.            [pr [forget it!]]
  604.         >end
  605.         check.for.favorites defined
  606.  
  607. Dr.  Logo  also  lets you put comments  in  your  procedures.  A
  608. comment  is  text  that Dr. Logo ignores and  does  not  try  to
  609. evaluate  or  execute.  You can use  comments  to  describe  the
  610. function or purpose of a procedure or expression. You can  start
  611. a  comment  at  the  beginning  of a  line  or  after  the  last
  612. expression on the line, but a comment must be the last object on
  613. the  line. Start a comment with a semicolon (";"), as  shown  in
  614. the following example. Also see Colorplate 3.
  615.  
  616.         ?to triangle  ; Draw an equilateral tri!
  617.         angle
  618.         >repeat 3 [forward 20 right 120]
  619.         >end
  620.         triangle defined
  621.         ?to flag
  622.         >fd 40
  623.         >triangle
  624.         >back 40  ; Return to original position
  625.         >end
  626.         flag defined
  627.  
  628. Comments take up space, but if space becomes a problem, you  can
  629. use  the  "noformat"  primitive to  remove  comments  from  your
  630. workspace.
  631.  
  632.  
  633. 2.1.3 Using variables in procedures
  634. -----------------------------------
  635.  
  636. Variables have special capabilities within a procedure. You  can
  637. use  variables  to  define inputs to a procedure,  and  to  pass
  638. information between procedures.
  639.  
  640. In  general,  it  is  not  good  programming  practice  to  bury
  641. constants in your procedures. In the following procedure, 40  is
  642. a constant:
  643.  
  644.         ?to flag
  645.         >forward 40
  646.         >triangle
  647.         >back 40
  648.         >end
  649.         flag defined
  650.  
  651. Constants  do not mean much to someone who reads your  procedure
  652. later.  And  because they might appear on more  than  one  line,
  653. constants   are  difficult  to  change   systematically.   Using
  654. variables  instead  of constants simplifies your  procedures.  A
  655. variable name can tell a person reading your procedure something
  656. about  the data object. And to change the data, you need  change
  657. only the make expression.
  658.  
  659.         ?to flag
  660.         >make "pole 40
  661.         >forward :pole
  662.         >triangle
  663.         >back :pole
  664.         >end
  665.         flag defined
  666.  
  667. To simplify your procedure even further, you can use a  variable
  668. on a procedure's title line to define an input.
  669.  
  670.         ?to flag :pole
  671.         >forward :pole
  672.         >triangle
  673.         >back :pole
  674.         >end
  675.         flag defined
  676.  
  677. A  variable  on the title line makes your procedure  require  an
  678. input.  When  your  procedure  is called,  Dr.  Logo  defines  a
  679. variable  that  has  the  name given  on  the  title  line.  The
  680. variable's value is the input object. If no object is input, Dr.
  681. Logo complains.
  682.  
  683.         ?flag
  684.         Not enough inputs to flag
  685.         ?flag 80
  686.         ?flag 40
  687.  
  688. When you give your procedure a variable name as input, Dr.  Logo
  689. gives the contents of the variable to your procedure.
  690.  
  691.         ?make "big 80
  692.         ?make "small 40
  693.         ?flag :big
  694.         ?flag :small
  695.  
  696. The  next  few  paragraphs  tell how Dr.  Logo  keeps  track  of
  697. variable  definitions. At toplevel, Dr. Logo assigns  values  to
  698. variable names in your workspace. You define variables with make
  699. and  name  expressions directly to the interpreter's  ?  prompt.
  700. These are called "global variables".
  701.  
  702. Dr.  Logo keeps track of variables defined by each procedure  as
  703. it is executing. These are the variables your procedure  defines
  704. in   the  title  line  and  with  make  expressions.   Different
  705. procedures  can  have variables that have the  same  name.  Logo
  706. programmers sometimes say that variables defined by a  procedure
  707. are "bound" to their values by that procedure. See the following
  708. example.
  709.  
  710.         ?make "cookie.jar "snickerdoodle
  711.         ?to look.in :cookie.jar
  712.         >print :cookie.jar
  713.         >end
  714.         look.in defined
  715.         ?:cookie.jar
  716.         snickerdoodle
  717.         ?look.in "brownie
  718.         brownie
  719.         ?:cookie.jar
  720.         snickerdoodle
  721.  
  722. You can use a variable in your procedure that is not defined  by
  723. your  procedure.  At execution time, if the procedure  has  been
  724. called  by  another  procedure, Dr. Logo looks  to  see  if  the
  725. calling   procedure  defined  the  variable.  If  it   finds   a
  726. definition, it does not look any further. If it does not find  a
  727. definition,  it searches up the levels of calling procedures  to
  728. toplevel before it complains that the variable is undefined.
  729.  
  730. Because  Dr. Logo searches variable bindings this way,  you  can
  731. use  variables to pass information between procedures.  Usually,
  732. the  exchange happens this way: the called procedure accesses  a
  733. variable  defined  by  the calling  procedure.  It  changes  the
  734. definition of the variable, then returns control to the  calling
  735. procedure.  The calling procedure can then use  the  information
  736. the called procedure stored in the changed variable.
  737.  
  738. The  "local"  primitive  can hide a  variable  from  Dr.  Logo's
  739. search. If calling and called procedures are using variables  of
  740. the same name, as is unavoidably the case when a procedure calls
  741. itself,  a local expression in the called procedure prevents  it
  742. from altering the calling procedure's value of the variable.  An
  743. input to a procedure is always local to the procedure.
  744.  
  745.         ?to peek.in :cookie.jar
  746.         >(print "cookie.jar "contains :cookie.j!
  747.         ar
  748.         >look.again
  749.         >end
  750.         peek.in defined
  751.         ?to look.again
  752.         >; cookie.jar not defined here,
  753.         >; just used!
  754.         >(print [cookie.jar still contains] :co!
  755.         okie.jar
  756.         >end
  757.         look.again defined
  758.         ?peek.in "sugar
  759.         cookie.jar contains sugar
  760.         cookie.jar still contains sugar
  761.         ?to peer.in
  762.         >local "cookie.jar
  763.         >make "cookie.jar "choc.chip
  764.         >(print [cookie.jar contains] :cookie.j!
  765.         ar
  766.         >look.again
  767.         >end
  768.         peer.in defined
  769.         ?ern "cookie.jar
  770.         ?:cookie.jar
  771.         cookie.jar has no value
  772.         ?peer.in
  773.         cookie.jar contains choc.chip
  774.         cookie.jar still contains choc.chip
  775.         ?look.again
  776.         cookie.jar still contains              !
  777.         cookie.jar has no value in look.again: !
  778.         (print [cookie.jar still contains] :co !
  779.         okie.jar
  780.  
  781.  
  782. 2.2 Giving inputs to procedures
  783. -------------------------------
  784.  
  785. You  can  use  one  or more variables in the  title  line  of  a
  786. procedure  to define inputs to the procedure. Because  of  this,
  787. procedures you define always have a fixed number of inputs.
  788.  
  789. Most  primitives also require a fixed number of  input  objects.
  790. However, some primitives can accept a variable number of  inputs
  791. when  the expression is enclosed in parentheses ["("  and  ")"].
  792. Without  parentheses,  these  primitives  normally  require  two
  793. inputs. With parentheses, they accept more or fewer inputs  than
  794. are normally required, as shown in the following example.
  795.  
  796.         ?(word "sum "mer "sun "shine)
  797.         summersunshine
  798.         ?list : favorites
  799.         Not enough inputs to list
  800.         ?(list :favorites)
  801.         [[choc.chip peanut.but oatmeal.raisin !
  802.         cream.fill brownie pinwheel shortbread!
  803.         snickerdoodle]]
  804.  
  805. Most  procedures expect a certain kind of input. When you  input
  806. something  to  a  procedure, it is simply  an  object,  and  the
  807. variable name is its container. What the procedure does with the
  808. object  determines what kind of object is required. In  fact,  a
  809. procedure executes normally until it reaches an expression  that
  810. requires  a  different  kind of input  than  was  supplied.  For
  811. example, if a procedure requires a number as input, it will  not
  812. know  what  to do with a word, and Dr. Logo complains.  See  the
  813. following example and Colorplate 36.
  814.  
  815.         ?to pentagon :size
  816.         >pr [The five angles of a pentagon]
  817.         >pr [equal 360 / 5 or 72 degrees.]
  818.         >repeat 5 [fd :size rt 72]
  819.         >end
  820.         pentagon defined
  821.         ?pentagon 40
  822.         The five angles of a pentagon
  823.         equal 360 / 5 or 72 degrees.
  824.         ?pentagon "forty
  825.         The five angles of a pentagon
  826.         equal 360 / 5 or 72 degrees.
  827.         fd doesn't like forty as input in pent!
  828.         agon: repeat 5 [fd :size rt 72]
  829.  
  830. As  you write procedures that take words and numbers  apart  and
  831. then  put them back together, you might create a  quoted  number
  832. such  as  "123.  In general, Dr. Logo accepts  a  quoted  number
  833. anywhere  an  unquoted number is expected. It  also  accepts  an
  834. unquoted number where a quoted word is expected. For example,  a
  835. primitive that expects numbers as input accepts quoted numbers.
  836.  
  837.         ?sum "53 "42
  838.         95
  839.  
  840. A  primitive  that  expects  a word or  list  as  input  accepts
  841. unquoted numbers.
  842.  
  843.         ?first 9876
  844.         9
  845.  
  846. One  exception  is the "ascii" primitive. It requires  a  quoted
  847. character as input. "ascii" does not distinguish among numerals,
  848. letters, and symbols.
  849.  
  850.         ?ascii "2
  851.         50
  852.         ?ascii 2
  853.         ascii doesn't like 2 as input
  854.  
  855.  
  856. 2.3 Classifying procedures
  857. --------------------------
  858.  
  859. All procedures operate the same way. You use them by following a
  860. procedure  name  with  inputs in an  expression.  However,  Logo
  861. programmers sometimes find it convenient to classify procedures,
  862. that  is  to  say, to group procedures that  have  something  in
  863. common  together  and give the group a name.  For  example,  the
  864. procedures  that  come with Dr. Logo and make up  Dr.  Logo  are
  865. called "primitives".
  866.  
  867. Most  procedures  can be classified as either a  command  or  an
  868. operation. A command initiates an action. For example,  commands
  869. move  the  turtle, draw pictures, and display  text.  A  command
  870. procedure  generally  ends with "end" or  "stop".  An  operation
  871. returns  an  object: TRUE, FALSE, a word, number, or  list.  The
  872. last  expression  to be evaluated in an operation  procedure  is
  873. always  an  output  expression.  Of  course,  you  can  write  a
  874. procedure that initiates an action before it outputs an  object.
  875. However,   most  primitives  are  simple  commands   or   simple
  876. operations.  The  descriptions  in  Section  6,  "References  to
  877. Primitives", refer to primitives as operations or commands.
  878.  
  879. Note  that the po primitives, which display things on  the  text
  880. screen,  are commands, not operations. Commands such  as  pocall
  881. and  popkg format lists with spaces and tabs for display on  the
  882. screen,  making  the lists inappropriate for  input  to  another
  883. procedure.
  884.  
  885. Logo programmers also use classification names to describe kinds
  886. of operations. Logical operations such as "and", "not", and "or"
  887. return  either  TRUE  or FALSE. An expression  that  contains  a
  888. logical  operator  and, therefore, evaluates to either  TRUE  or
  889. FALSE is called a "predicate expression". Because of this, other
  890. logical operation names end with p. For example,
  891.  
  892.         ?numberp "two
  893.         FALSE
  894.         ?numberp 2
  895.         TRUE
  896.  
  897. Other   logical  operators  you  can  use  to   form   predicate
  898. expressions are equalp, emptyp, memberp, listp, and wordp.  When
  899. you  write  a  procedure that outputs TRUE or  FALSE,  give  the
  900. procedure  a  name  that ends with p to indicate that  it  is  a
  901. logical operation.
  902.  
  903. Arithmetic   operations   output   numbers.   Most    arithmetic
  904. expressions  are  formed  normally,  with  the  procedure   name
  905. followed by its inputs.
  906.  
  907.         ?product 2 3
  908.         6
  909.  
  910. However, some arithmetic operations are defined by symbols: +  -
  911. *  /  ^,  instead  of names.  Some  logical  operations,  called
  912. "relational  operators",  also use symbols: < >  =,  instead  of
  913. procedure   names.  Procedures  that  use  symbols  instead   of
  914. procedure names can be infix operators, which means you can  put
  915. the  symbol between the inputs in the expression. These  symbols
  916. also  work  as  prefix operators,  where  the  primitive  symbol
  917. precedes its inputs.
  918.  
  919.         ?2 * 3
  920.         6
  921.         ?= 2 2
  922.         TRUE
  923.  
  924.  
  925. 2.4 Evaluating procedures
  926. -------------------------
  927.  
  928. The  Dr.  Logo interpreter evaluates one line at a time  as  you
  929. type  lines  at  your keyboard. Dr.  Logo  also  evaluates  your
  930. procedures  one  line  at a time. When an  expression  within  a
  931. procedure  begins  with the name of a different  procedure,  Dr.
  932. Logo  must execute the called procedure before it can return  to
  933. evaluate  the next line of the calling procedure. It  must  also
  934. keep track of where it stopped executing the calling  procedure,
  935. in case the called procedure calls yet another procedure.
  936.  
  937. To do this, Dr. Logo uses a stack. At toplevel, there is nothing
  938. on the stack. During the execution of a procedure, there is  one
  939. procedure  on the stack until it calls another; then, there  are
  940. two.  If the second procedure calls a third, there are three  on
  941. the  stack, and so on. The number of procedures on the stack  is
  942. sometimes  called  the level number.  The  debugging  facilities
  943. "trace"  and  "watch"  display the level  number  as  procedures
  944. execute. Toplevel is level number 0.
  945.  
  946. Dr. Logo assigns part of memory to the stack. Dr. Logo also uses
  947. this part of memory to store the values of local variables. If a
  948. procedure calls itself and the level number becomes very  large,
  949. or  if the procedure defines a great many local  variables,  the
  950. stack space might fill up. When this occurs, Dr. Logo displays a
  951. message and stops executing the procedure.
  952.  
  953. When  a  procedure is never called by any other  procedure,  but
  954. does call on other procedures itself, Logo programmers  classify
  955. it   as  a  superprocedure  and  the  procedures  it  calls   as
  956. subprocedures.  Dr. Logo's potl primitive displays the names  of
  957. the  superprocedures  in  your workspace.  A  pocall  expression
  958. displays the subprocedures called by the input-named  procedure.
  959. A poref expression displays the procedures that call the  input-
  960. named procedure.
  961.  
  962.  
  963. EOF
  964. DRLRM3.WS4      (= "Dr. Logo Reference Manual", Section 3)
  965. ----------
  966.  
  967. (Retyped by Emmanuel ROCHE.)
  968.  
  969.  
  970. Section 3: Editing commands
  971. ---------------------------
  972.  
  973. To edit with Dr. Logo means to enter new text, or to change text
  974. you  have already entered. Editing can be as simple as fixing  a
  975. typing  error  in a line you have typed to the  interpreter's  ?
  976. prompt,  or  as complex as defining several long  procedures  at
  977. once in Dr. Logo's screen editor.
  978.  
  979. Dr.  Logo gives you three ways to edit: line editing,  procedure
  980. editing,  and screen editing. You use line editing  commands  in
  981. both procedure and screen editing. Procedure editing is a simple
  982. extension  of  line  editing,  and  screen  editing  builds   on
  983. procedure editing. This section tells when, why, and how to  use
  984. Dr.  Logo's line editing, procedure editing, and screen  editing
  985. commands.
  986.  
  987. You give the commands described in this section to Dr. Logo with
  988. control  characters,  not with expressions. To enter  a  control
  989. character,  hold  down  the control key  (marked  Ctrl  on  your
  990. keyboard)  and  press the required letter key. Not  all  of  Dr.
  991. Logo's control character commands edit text; some interrupt  and
  992. terminate  procedure  execution. The last part of  this  section
  993. introduces Dr. Logo miscellaneous control character commands.
  994.  
  995.  
  996. 3.1 Line editing
  997. ----------------
  998.  
  999. You  can use line editing commands to correct any text  you  are
  1000. entering  to  Dr. Logo. When you write a program that  asks  the
  1001. user  to type something at the keyboard, the user can  also  use
  1002. line  editing commands to change his input. The following  table
  1003. summarizes Dr. Logo's line editing control characters.
  1004.  
  1005. Table 3-1. Line editing control characters
  1006.  
  1007. Format: Character
  1008.         Effect
  1009.  
  1010. Ctrl-A
  1011. Moves the cursor to the beginning of the line.
  1012.  
  1013. Ctrl-B
  1014. Moves the cursor [B]ack one character; that is to say, it  moves
  1015. the cursor one position to the left.
  1016.  
  1017. Ctrl-D
  1018. [D]eletes the character indicated by the cursor.
  1019.  
  1020. Ctrl-E
  1021. Moves the cursor to the [E]nd of the line.
  1022.  
  1023. Ctrl-F
  1024. Moves  the  cursor [F]orward one character; that is to  say,  it
  1025. moves the cursor one position to the right.
  1026.  
  1027. Ctrl-H
  1028. Deletes the character to the left of the cursor.
  1029.  
  1030. Ctrl-I
  1031. [I]nserts a tab (three spaces).
  1032.  
  1033. Ctrl-K
  1034. [K]ills  the  remaining  line; that is to say,  it  deletes  all
  1035. characters  right of the cursor to the end of the line.  Deleted
  1036. characters are stored in buffer.
  1037.  
  1038. Ctrl-Y
  1039. [Y]anks  text from the buffer; that is to say,  redisplays  line
  1040. most  recently  stored  in  the buffer by  an  Enter  or  Ctrl-K
  1041. keystroke.
  1042.  
  1043.  
  1044. The  following  examples  show how you  can  use  these  control
  1045. characters  when  you are entering expressions to the  Dr.  Logo
  1046. interpreter.  In these examples, the underbar  ("_")  represents
  1047. the cursor.
  1048.  
  1049. Once  you have typed a line, you can use control  characters  to
  1050. move  the  cursor  left and right over the text.  You  can  make
  1051. corrections anywhere in the command line.
  1052.  
  1053.         ?repaet 36 [fd 8 lf 10]_        (repeat and lt mistyped)
  1054.         ?r_epaet 36 [fd 8 lf 10]         (Ctrl-A to beginning of line)
  1055.         ?repaet_ 36 [fd 8 lf 10]         (Ctrl-F to move cursor right)
  1056.         ?rept_ 36 [fd 8 lf 10]           (Ctrl-H deletes chars to the left)
  1057.         ?repeat_ 36 [fd 8 lf 10]         (ea corrects repeat)
  1058.         ?repeat 36 [fd 8 lf 10]_        (Ctrl-E to end of line)
  1059.         ?repeat 36 [fd 8 lf_ 10]         (Ctrl-B moves cursor left)
  1060.         ?repeat 36 [fd 8 l_ 10]          (Ctrl-D deletes cursor position)
  1061.         ?repeat 36 [fd 8 lt_ 10]         (t corrects lt)
  1062.  
  1063. You can press the Enter key to send your command to Dr. Logo  no
  1064. matter  which character the cursor is indicating in the  command
  1065. line.  When you press Enter to send a line to  the  interpreter,
  1066. Dr. Logo stores the line in a buffer. You can recall the  stored
  1067. line  with  Ctrl-Y.  This is handy if you want  to  execute  the
  1068. command again, execute it again with a minor modification, or if
  1069. you  made a typing error and pressed Enter before you  corrected
  1070. it.
  1071.  
  1072.         ?save figures
  1073.         I don't know how to figures
  1074.         ?save figures_          (Ctrl-Y recalls line)
  1075.         ?save "f_igures          (Ctrl-B moves cursor left;
  1076.                                 (" corrects line.)
  1077.         ?save "figures_         (Save file on default drive; Enter
  1078.                                  then Ctrl-Y recalls line.)
  1079.         ?save "f_igures          (Ctrl-B moves cursor left)
  1080.         ?save "b:f_igures        (b: to make copy on disk b: Enter)
  1081.  
  1082. You  can delete all or part of a line with a Ctrl-K command.  If
  1083. you have second thoughts, you can recall the deleted  characters
  1084. with Ctrl-Y.
  1085.  
  1086.         ?erns "figure.pack_     (erase names? maybe not...)
  1087.         ?e_rns "figure.pack      (Ctrl-A to beginning of line)
  1088.         ?_                      (Ctrl-K erases line)
  1089.         ?erns "figure.pack_     (Yes, erase names; Ctrl-Y recalls line)
  1090.  
  1091. You  can  also use Ctrl-K and Ctrl-Y to repeat a  portion  of  a
  1092. command line.
  1093.  
  1094.         ?(pr "I char 3 "N "Y
  1095.         I o N Y
  1096.         ?(pr "I char 3 "N "Y    (Ctrl-Y recalls line)
  1097.         ?(pr "_I char 3 "N "Y    (Ctrl-B moves cursor left)
  1098.         ?(pr _                  (Ctrl-K erases part of line)
  1099.         ?(pr "I char 3 "N "Y_   (Ctrl-Y recalls partial line)
  1100.         ?(pr "I char 3 "N "Y "  "I char 3 "N "Y "  "I char 3 "N "Y "
  1101.                                 (Quoted blank spaces and Ctrl-Y
  1102.                                  keystrokes extend command.)
  1103.         I o N Y  I o N Y  I o N Y
  1104.  
  1105.  
  1106. 3.2 Procedure editing
  1107. ---------------------
  1108.  
  1109. When you are interacting with the Dr. Logo interpreter, during a
  1110. pause, or while watching a procedure's executon, you can use the
  1111. special  words  "to"  and "end" to enter  and  exit  Dr.  Logo's
  1112. procedure editor. For example, when you type a line that  begins
  1113. with  "to"  to the interpreter's ? prompt, Dr. Logo  enters  the
  1114. procedure editor.
  1115.  
  1116.         ?to circle :size
  1117.         >repeat 36 [fd :size rt 10]
  1118.         >end
  1119.         circle defined
  1120.         ?
  1121.  
  1122. The  procedure editor's prompt, >, tells you that Dr. Logo  will
  1123. not  immediatelly evaluate the expressions you enter  to  define
  1124. the new procedure. Within the procedure editor, you can use  any
  1125. of  the  line editing control characters commands  to  move  the
  1126. cursor, correct errors, delete characters and lines, and  recall
  1127. lines.
  1128.  
  1129. To  exit the procedure editor, you must enter the  special  word
  1130. "end"  by  itself as the last line of the  procedure.  After  it
  1131. reads  an end line, Dr. Logo defines the procedure  and  returns
  1132. you  to  the  situation from which  you  entered  the  procedure
  1133. editor.
  1134.  
  1135.  
  1136. 3.3 Screen editing
  1137. ------------------
  1138.  
  1139. To  make changes to a defined procedure without  reentering  the
  1140. complete procedure definition to the procedure editor, you  must
  1141. use  Dr. Logo's screen editor. Using the screen editor, you  can
  1142. move  from line to line in a procedure and make changes in  each
  1143. line. You can also load any number of procedures into the screen
  1144. editor  and make changes to each one. In addition, you  can  use
  1145. the screen editor to change the contents of variables.
  1146.  
  1147. The  screen  editor is smart; that is to say, it  makes  certain
  1148. assumptions  about your objectives for an editing  session.  For
  1149. example,  if  you define a procedure in the  screen  editor  and
  1150. forget  to  enter "end", the screen editor adds an end  line  to
  1151. your  procedure.  When the execution of one of  your  procedures
  1152. produces  an  error message and you call the screen  editor,  it
  1153. assumes  that  you want to edit  that  procedure,  automatically
  1154. loads  that procedure into itself, and positions the  cursor  at
  1155. the line in which the error occurred.
  1156.  
  1157. As  with the procedure editor, you can enter the  screen  editor
  1158. while interacting with the interpreter, during a pause, or while
  1159. you are WATCHing the execution of a procedure. You cannot  write
  1160. a procedure that uses the screen editor.
  1161.  
  1162. Before  you  can use the screen editor to make changes  to  your
  1163. procedures  or  variables, you must load the ones  you  want  to
  1164. change  into  the screen editor's buffer.  The  screen  editor's
  1165. buffer is its own private workspace. Within the buffer, you  can
  1166. make  changes, add text, and delete text. However,  the  changes
  1167. you make do not become a part of Dr. Logo's workspace until  you
  1168. exit  the screen editor. The changes must become a part  of  Dr.
  1169. Logo's workspace before you can save them on disk.
  1170.  
  1171. There  are  four primitives that load procedures  and  variables
  1172. into the screen editor's buffer and enter the screen editor. All
  1173. four  start  with "ed". Each one enters the screen  editor;  the
  1174. only difference between these primitives is what they load  into
  1175. the screen editor's buffer. The descriptions of these primitives
  1176. in Section 6, "References to Primitives", tell what input  names
  1177. these primitives require to load selective groups of  procedures
  1178. and  variables  into the screen editor's buffer.  The  following
  1179. table describes these four primitives.
  1180.  
  1181. Table 3-2. Load primitives
  1182.  
  1183. Format: Primitive
  1184.         Purpose
  1185.  
  1186. edit (ed)
  1187. Use edit, or its abbreviation ed, to load a procedure or a  list
  1188. of procedures into the screen editor's buffer. If the  execution
  1189. of  a  procedure  has  ended  with  an  error  message  and  you
  1190. immediately  enter  edit without an input  procedure  name,  the
  1191. screen  editor automatically loads the erroneous procedure  into
  1192. the buffer, and positions the cursor at the offending line.
  1193.  
  1194. edall
  1195. Use edall to load both variables and procedures into the  screen
  1196. editor's  buffer.  "edall"  without  an  input  name  loads  all
  1197. procedures and variables in Dr. Logo's workspace into the screen
  1198. editor's buffer.
  1199.  
  1200. edns
  1201. Use  edns  to load a group of variables, names into  the  screen
  1202. editor's  buffer.  "edns"  without  an  input  name  loads   all
  1203. variables  in  Dr.  Logo's workspace into  the  screen  editor's
  1204. buffer.
  1205.  
  1206. edps
  1207. Use edps to load a group of procedures into the screen  editor's
  1208. buffer. "edps" without an input name loads all procedures in Dr.
  1209. Logo's workspace into the screen editor's buffer.
  1210.  
  1211.  
  1212. When  you  use  one of these primitives  and  enter  the  screen
  1213. editor, it clears all normal text from the screen, and  displays
  1214. only  the  contents of its buffer. The screen  editor  does  not
  1215. display  a  prompt  character,  but  the  cursor  indicates  the
  1216. location  that  an insertion or control character  command  will
  1217. affect.
  1218.  
  1219. While  in  the screen editor, you can use all the  line  editing
  1220. control characters described in Section 3.1, "Line Editing",  to
  1221. make  corrections within lines. The table below  summarizes  the
  1222. screen editing control characters you can use to move the cursor
  1223. from  line  to line, to page through the buffer,  and  exit  the
  1224. screen editor.
  1225.  
  1226. Table 3-3. Screen editing control characters
  1227.  
  1228. Format: Character
  1229.         Effect
  1230.  
  1231. Ctrl-C
  1232. Exits   screen  editor;  updates  Dr.  Logo's   workspace   with
  1233. definitions of all procedures and variables from screen editor's
  1234. buffer.
  1235.  
  1236. Ctrl-G
  1237. Exits  screen editor but does not update Dr.  Logo's  workspace.
  1238. Any   changes  made  during  the  screen  editing  session   are
  1239. discarded.
  1240.  
  1241. Ctrl-L
  1242. Readjusts display so that line currently indicated by the cursor
  1243. is positioned at the center of the screen. If the cursor is less
  1244. than  12  lines  from the beginning of the  buffer,  the  screen
  1245. editor simply beeps when Ctrl-L is pressed.
  1246.  
  1247. Ctrl-N
  1248. Moves  the cursor to the [N]ext line; the cursor moves down  one
  1249. line towards the end of the buffer.
  1250.  
  1251. Ctrl-O
  1252. [O]pens a new line. A Ctrl-O keystroke is equivalent to pressing
  1253. Enter followed by Ctrl-B.
  1254.  
  1255. Ctrl-P
  1256. Moves  cursor  to the [P]revious line; the cursor moves  up  one
  1257. line towards the beginning of the buffer.
  1258.  
  1259. Ctrl-V
  1260. Displays  the  next screenfull of text in  the  screen  editor's
  1261. buffer, the next 24 lines towards the bottom of the buffer.
  1262.  
  1263. ESC-V
  1264. Displays the previous screenfull of text in the screen  editor's
  1265. buffer,  the  previous  24 lines towards the  beginning  of  the
  1266. buffer.
  1267.  
  1268. ESC-<
  1269. Positions  the  cursor at the beginning of the  screen  editor's
  1270. buffer.
  1271.  
  1272. ESC->
  1273. Positions the cursor at the end of the screen editor's buffer.
  1274.  
  1275.  
  1276. The  following  examples show how you can combine  these  screen
  1277. editing control characters with line editing control  characters
  1278. for editing shortcuts. Several combinations of control character
  1279. commands  are  convenient and worth remembering.  Ctrl-E  Ctrl-D
  1280. deletes  the  Carriage Return between two lines and  makes  them
  1281. into  one  line.  Ctrl-A  Ctrl-K  deletes  the  line   currently
  1282. indicated by the cursor. You can combine Ctrl-O with Ctrl-Y  and
  1283. Ctrl-K to quickly move a line within the screen editor. The line
  1284. moved  below makes the countdown procedure print a 0  before  it
  1285. stops.  The edit is performed with only eight control  character
  1286. commands.
  1287.  
  1288.         ?countdown 4
  1289.         4
  1290.         3
  1291.         2
  1292.         1
  1293.         ?ed "countdown
  1294.                                 (editor clear screen)
  1295.         to countdown :number_
  1296.         if :number = 0 [stop]
  1297.         pr :number
  1298.         countdown :number - 1
  1299.         end
  1300.                                 (Ctrl-N Ctrl-A positions cursor
  1301.                                  at line to be moved)
  1302.         to countdown :number
  1303.         i_f :number = 0 [stop]
  1304.         pr :number
  1305.         countdown :number - 1
  1306.         end
  1307.                                 (Ctrl-K deletes line)
  1308.         to countdown :number
  1309.         _
  1310.         pr :number
  1311.         countdown :number - 1
  1312.         end
  1313.                                 (Ctrl-N positions cursor at new location)
  1314.         to countdown :number
  1315.  
  1316.         pr :number
  1317.         c_ountdown :number - 1
  1318.         end
  1319.                                 (INS Ctrl-Y inserts line)
  1320.         to countdown :number
  1321.  
  1322.         pr :number
  1323.         i_f :number = 0 [stop]
  1324.         countdown :number - 1
  1325.         end
  1326.                                 (Ctrl-C defines procedure.)
  1327.         countdown defined
  1328.         ?countdown 4
  1329.         4
  1330.         3
  1331.         2
  1332.         1
  1333.         0
  1334.         ?
  1335.  
  1336. The  paging  control character commands become useful  when  you
  1337. have  more than 24 lines of text in the screen editor's  buffer.
  1338. You can enter edall to load everything from Dr. Logo's workspace
  1339. into  the screen editor's buffer, then experiment  with  Ctrl-L,
  1340. Ctrl-V, ESC-V, ESC-<, and ESC->.
  1341.  
  1342. To exit the screen editor normally, press Ctrl-C. In this  case,
  1343. Dr. Logo updates the definitions of procedures and variables  in
  1344. its  workspace  with the definitions from  the  screen  editor's
  1345. buffer. If you have modified the title line of a procedure,  Dr.
  1346. Logo  defines a new procedure and does not change  the  original
  1347. definition  of the procedure currently in the workspace. If  you
  1348. omitted an end line at the end of a procedure, Dr. Logo adds one
  1349. as it updates its workspace.
  1350.  
  1351. To discard the changes you have made during an editing  session,
  1352. exit  the  screen  editor with Ctrl-G. This  leaves  Dr.  Logo's
  1353. workspace  in the same condition you found it when  you  entered
  1354. the screen editor.
  1355.  
  1356. When  you  exit the screen editor, Dr. Logo returns you  to  the
  1357. same  situation  from  which you entered. For  example,  if  you
  1358. entered  the  screen editor during a pause in a  procedure,  Dr.
  1359. Logo returns to the appropriate pause prompt and waits for  your
  1360. next command.
  1361.  
  1362. In  a  certain  situation,  you can use  a  few  screen  editing
  1363. commands  outside the screen editor. This situation occurs  when
  1364. you are entering a long expression outside the screen editor and
  1365. Dr. Logo prints a "!" before starting on the next line. In  this
  1366. case, you can use Ctrl-P and Ctrl-N to move up and down  between
  1367. lines.  You  can  also use Ctrl-O to open a new  line,  but  all
  1368. characters  right of the Ctrl-O keystroke are ignored; Dr.  Logo
  1369. treats  the  Ctrl-O as the end of the expression.  However,  the
  1370. characters are not lost. You can recall them with Ctrl-Y.
  1371.  
  1372.  
  1373. 3.4 Other control character commands
  1374. ------------------------------------
  1375.  
  1376. Dr.  Logo  recognizes  several control  character  commands  for
  1377. actions  other  than  line editing. In fact,  the  only  control
  1378. characters that have no meaning for Dr. Logo are Ctrl-U, Ctrl-J,
  1379. Ctrl-R,  and Ctrl-X. The remaining control characters  terminate
  1380. and interrupt procedure execution and scrolling screen displays,
  1381. and  switch between a full graphics screen, a full text  screen,
  1382. and  a  split  screen. Section 4, "Text  and  Graphic  Screens",
  1383. describes  screen  control  character commands  in  detail.  The
  1384. following  table summarizes the miscellaneous control  character
  1385. commands.
  1386.  
  1387. Table 3-4. Additional control character commands
  1388.  
  1389. Format: Character
  1390.         Effect
  1391.  
  1392. Ctrl-G
  1393. Immediately terminates the currently executing procedure.
  1394.  
  1395. Ctrl-L
  1396. Displays  a full graphics screen; devotes the monitor to  turtle
  1397. graphics.
  1398.  
  1399. Ctrl-M
  1400. Carriage Return; same as pressing the Enter key.
  1401.  
  1402. Ctrl-Q
  1403. Generates  the  [Q]uoting character ("\") that  makes  Dr.  Logo
  1404. treat a delimiter character as a literal character.
  1405.  
  1406. Ctrl-S
  1407. Displays a [S]plitscreen; divides the monitor between a  partial
  1408. graphic screen and a text window.
  1409.  
  1410. Ctrl-T
  1411. Displays a full [T]ext screen; devotes the monitor to text.
  1412.  
  1413. Ctrl-W
  1414. Interrupt  the  scrolling of a text display; [W]aits  until  the
  1415. next keystroke to continue the display.
  1416.  
  1417. Ctrl-Z
  1418. Interrupts  the  currently executing procedure,  displays  pause
  1419. prompt  to allow interactive debugging. Enter "co"  to  continue
  1420. execution of interrupted procedure.
  1421.  
  1422.  
  1423. EOF
  1424. DRLRM4.WS4      (= "Dr. Logo Reference Manual", Section 4)
  1425. ----------
  1426.  
  1427. (Retyped by Emmanuel ROCHE.)
  1428.  
  1429.  
  1430. Section 4: Text and graphic screens
  1431. -----------------------------------
  1432.  
  1433. One  of  Dr.  Logo's  most exciting  capabilities  on  your  IBM
  1434. Personal Computer is to create graphic designs and display  text
  1435. in  many beautiful colors. Dr. Logo shows you a graphics  cursor
  1436. called "the turtle", which dutifully draws designs according  to
  1437. your  instructions. However, this section does not tell you  how
  1438. to control the turtle; it tells you how to control the  physical
  1439. properties  of your display. It tells what combinations of  text
  1440. and  graphics  are  possible, how to  switch  between  text  and
  1441. graphic  screens, and how to control the colors of drawings  and
  1442. text.
  1443.  
  1444.  
  1445. 4.1 Monitors, screens, and windows
  1446. ----------------------------------
  1447.  
  1448. In  memory, Dr. Logo maintains two screens: a text screen and  a
  1449. graphic screen. A text screen contains only text, with up to  80
  1450. characters in one line. The text screen never contains more than
  1451. 25  lines. A graphic screen can contain drawings and  text,  but
  1452. can  have  only 40 characters in one line.  The  graphic  screen
  1453. potentially  extends  beyond  the range  of  your  monitor. The
  1454. portion of the graphic screen your monitor can display is called
  1455. "the visual field".
  1456.  
  1457. Dr. Logo maintains these complete screens in memory, so that  it
  1458. can  display combinations of parts of them on your  monitor  and
  1459. restore  the  full display of either screen.  You  control  what
  1460. combination  of text and graphics appears on your  monitor  with
  1461. Dr.  Logo primitives and control character commands. Your  color
  1462. monitor can display both text and graphic screens. A  monochrome
  1463. monitor can display only the text screen.
  1464.  
  1465. To let you see the text of your procedures, or your  interaction
  1466. with  the interpreter, without devoting your entire  monitor  to
  1467. screen, Dr. Logo can direct part of the text screen into a  text
  1468. window. When a window of text appears on the graphic screen, the
  1469. combination of text and graphics is called "a splitscreen". When
  1470. you  enter "debug", Dr. Logo divides the monitor into  two  text
  1471. windows, then directs text displayed by a procedure to the lower
  1472. PROGRAM  window, and text displayed by debugging  facilities  to
  1473. the upper DEBUG window.
  1474.  
  1475.  
  1476. 4.2 Displaying text and graphic screens
  1477. ---------------------------------------
  1478.  
  1479. Dr. Logo supports both primitives and control character commands
  1480. that  make your monitor display the text screen and the  graphic
  1481. screen  in various combinations, as described in  the  following
  1482. table.
  1483.  
  1484. Table 4-1. Displaying screens
  1485.  
  1486. Format: Control character
  1487.         Primitive
  1488.         Display
  1489.  
  1490. Ctrl-L
  1491. fullscreen
  1492. Displays a full graphic screen; devotes the monitor to graphics.
  1493.  
  1494. Ctrl-S
  1495. splitscreen
  1496. Displays  a splitscreen; divides the monitor between  a  partial
  1497. graphic screen and a text window.
  1498.  
  1499. Ctrl-T
  1500. textscreen
  1501. Displays a full text screen; devotes the monitor to text.
  1502.  
  1503. (no control character)
  1504. debug
  1505. Displays two text windows on the monitor.
  1506.  
  1507. (no control character)
  1508. nodebug
  1509. Closes  text  windows, returns monitor to a  cleared  full  text
  1510. screen.
  1511.  
  1512.  
  1513. The  control character commands are the quickest way  to  switch
  1514. displays while you are interacting with the interpreter. Use the
  1515. fullscreen, splitscreen, and textscreen primitives when you want
  1516. to switch displays within a procedure. You must always use debug
  1517. and  nodebug to control the two debugging text windows.  "debug"
  1518. disables   Ctrl-S   and  splitscreen;  you  cannot   display   a
  1519. splitscreen  while  you are using the  debugging  text  windows.
  1520. "nodebug" restores Ctrl-S and splitscreen.
  1521.  
  1522. When  you  are using one color monitor, Dr.  Logo  automatically
  1523. displays  a splitscreen when you enter a command that moves  the
  1524. turtle.  However,  Dr.  Logo  can support both  a  color  and  a
  1525. monochrome  monitor.  When  you  have  two  monitors,  Dr.  Logo
  1526. automatically  displays  the  text  screen  on  the   monochrome
  1527. monitor, and the graphic screen on the color monitor.
  1528.  
  1529. Having two monitors changes the way some of the display  control
  1530. primitives  work. When you have two monitors, Dr. Logo does  not
  1531. automatically  display a splitscreen when you enter  a  graphics
  1532. command  because  full  graphic  and  text  screens  are  always
  1533. displayed. However, you can use Ctrl-S and splitscreen to open a
  1534. text  window  on the graphic screen. To remove  the  splitscreen
  1535. text  window and display the full text screen on the  monochrome
  1536. monitor,  you can use fullscreen, Ctrl-L, or Ctrl-T. If you  use
  1537. textscreen  at  any  time  on a two  monitor  system,  Dr.  Logo
  1538. displays the text screen on the color monitor.
  1539.  
  1540.  
  1541. 4.3 Text screen
  1542. ---------------
  1543.  
  1544. The text screen has positions for 2000 text characters: 25 lines
  1545. of text with 80 characterrs in each line. The coordinate  system
  1546. shown below references these characters. A text coordinate  list
  1547. contains two numbers: the first is the row or character  number,
  1548. and the second is the line number.
  1549.  
  1550.           [0 0]                           [79 0]
  1551.                 +-----------------------+
  1552.                 |                       |
  1553.                 |                       |
  1554.                 |                       |
  1555.                 |                       |
  1556.                 |                       |
  1557.                 +-----------------------+
  1558.          [0 24]                           [79 24]
  1559.  
  1560. You use this coordinate system with "setcursor" to position  the
  1561. cursor within the text screen.
  1562.  
  1563. Dr. Logo lets you control the foreground and background color of
  1564. each  character cell. "textbg" sets the background of  the  text
  1565. screen  to the color represented by the input number. There  are
  1566. eight  possible  colors, so normally you input a number  in  the
  1567. range  0 to 7. However, textbg also controls whether or not  the
  1568. foreground  characters  blink. To display  blinking  characters,
  1569. input  a  number  between 8 and 15 to textbg, as  shown  in  the
  1570. following table.
  1571.  
  1572. Table 4-2. Background colors
  1573.  
  1574. Normal  Blinking        Background color
  1575. ------  --------        ----------------
  1576.   0         8           Black
  1577.   1         9           Blue
  1578.   2        10           Green
  1579.   3        11           Cyan
  1580.   4        12           Red
  1581.   5        13           Magenta
  1582.   6        14           Brown
  1583.   7        15           Grey
  1584.  
  1585. "textfg"  sets  the foreground of the text screen to  the  color
  1586. represented  by  the  input number. The  IBM  Personal  Computer
  1587. supports  16 foreground colors, but if your color  monitor  does
  1588. not support two levels of intensity, you can see only the  first
  1589. eight colors listed in the following table.
  1590.  
  1591. Table 4-3. Foreground colors
  1592.  
  1593. Input   Foreground      Input   Foreground
  1594. number    colors        number    colors
  1595. ------  ----------      ------  ----------
  1596.   0       Black            8      Black
  1597.   1       Blue             9      Bright blue
  1598.   2       Green           10      Bright green
  1599.   3       Cyan            11      Bright cyan
  1600.   4       Red             12      Bright red
  1601.   5       Magenta         13      Bright magenta
  1602.   6       Brown           14      Yellow
  1603.   7       Grey            15      White
  1604.  
  1605.  
  1606. 4.4 Graphic screen
  1607. ------------------
  1608.  
  1609. Dr.  Logo  gives you complete control of the  60,000  individual
  1610. dots that make up the visual field of your graphic screen; there
  1611. are 300 dots horizontally and 200 dots vertically.  Technically,
  1612. these  dots are called "pixels". A turtle step is equivalent  to
  1613. one  dot.  For example, when you enter "forward 1",  the  turtle
  1614. moves  forward one pixel. The dots make any diagonal  lines  the
  1615. turtle  draws seem jagged. Although Dr. Logo  calculates  angles
  1616. and  headings  with great precision, the turtle  rounds  to  the
  1617. nearest degree before drawing.
  1618.  
  1619.  
  1620. 4.4.1 Graphic coordinates and the visual field
  1621. ----------------------------------------------
  1622.  
  1623. You can reference each dot on the graphic screen individually by
  1624. its  coordinates.  Using coordinates, you can quickly  move  the
  1625. turtle  to  any location on the screen (setpos), or  change  any
  1626. single dot to the turtle's current pencolor (dot).
  1627.  
  1628. A  graphic  screen coordinate list contains two  numbers:  an  x
  1629. coordinate indicates the horizontal position, and a y coordinate
  1630. indicates the vertical position. For example, the coordinates of
  1631. the turtle's home position are [0 0], the center of the  screen.
  1632. To reference a dot in the visual graphic field, the x coordinate
  1633. can be in the range -160 to +159, and the y coordinate can be in
  1634. the range -99 to +100.
  1635.  
  1636.      [-160 100]                           [159 100]
  1637.                 +-----------------------+
  1638.                 |                       |
  1639.                 |                       |
  1640.                 |         [0 0]         |
  1641.                 |                       |
  1642.                 |                       |
  1643.                 +-----------------------+
  1644.      [-160 -99]                           [159 -99]
  1645.  
  1646. When you first start Dr. Logo, the visual field is just a window
  1647. on  a  greater graphics plane. You can use numbers  outside  the
  1648. visual  coordinate  ranges to reference  positions  outside  the
  1649. visual  field;  the turtle can draw a part of a design  off  the
  1650. monitor and return. You can limit the turtle to the visual field
  1651. with  two  primitives: fence and wrap. "fence" sets  a  boundary
  1652. around the edge of the visual field. When the turtle  encounters
  1653. the  boundary,  Dr. Logo complains "Turtle out  of  bounds"  and
  1654. stops any executing procedure. "wrap" makes the turtle  reappear
  1655. on  the  opposite  side  of the  monitor  when  it  exceeds  the
  1656. boundary. Use "window" to remove the boundary.
  1657.  
  1658.  
  1659. 4.4.2 Graphic text coordinates
  1660. ------------------------------
  1661.  
  1662. On  the  graphic  screen,  there  are  positions  of  1000  text
  1663. characters:  25 lines of text with 40 characters per  line.  The
  1664. coordinate system shown below references these character  cells.
  1665. In  a  text  coordinate list, the first number  is  the  row  or
  1666. character number, and the second number is the line number.
  1667.  
  1668.           [0 0]                           [39 0]
  1669.                 +-----------------------+
  1670.                 |                       |
  1671.                 |                       |
  1672.                 |                       |
  1673.                 |                       |
  1674.                 |                       |
  1675.                 +-----------------------+
  1676.          [0 24]                           [39 24]
  1677.  
  1678. You can use this coordinate system to position the cursor within
  1679. the splitscreen text window (setcursor), or to take input from a
  1680. lightpen (lpen).
  1681.  
  1682. When you use "turtletext" to display text on the graphic screen,
  1683. the  first  character of the input object appears in  the  first
  1684. character  cell  to the right of the turtle's center  line.  The
  1685. character  might  not appear directly under the  turtle  if  the
  1686. turtle is not on a character cell boundary.
  1687.  
  1688.  
  1689. 4.4.3 Graphic colors
  1690. --------------------
  1691.  
  1692. Although  your color monitor can display many different  colors,
  1693. the graphic screen can contain only four colors at any one time.
  1694. In Dr. Logo, the number you input to setbg specifies with set of
  1695. four colors you want your monitor to display.
  1696.  
  1697. First,  you have to select a background color. The IBM  Personal
  1698. Computer  supports  eight  background colors in  two  levels  of
  1699. intensity,  although  your  color  monitor  might  not   display
  1700. different   intensities.  The  numbers  setbg   accepts   select
  1701. background colors as described in the following table.
  1702.  
  1703. Table 4-4. Background color intensity
  1704.  
  1705. Low intensity           High intensity
  1706. -----------------       ------------------
  1707. 0 16 32 48  Black        8 24 40 56  Black
  1708. 1 17 33 49  Blue         9 25 41 57  Blue
  1709. 2 18 34 50  Green       10 26 42 58  Green
  1710. 3 19 35 51  Cyan        11 27 42 59  Cyan
  1711. 4 20 36 52  Red         12 28 43 60  Red
  1712. 5 21 37 53  Magenta     13 29 45 61  Magenta
  1713. 6 22 38 54  Yellow      14 30 46 62  Yellow
  1714. 7 23 40 55  White       15 31 47 63  White
  1715.  
  1716. Each  of  the four numbers for a background  color  specifies  a
  1717. different  pen for the turtle to use. The turtle has four  pens.
  1718. Each  pen  has four unique colors of ink, one of  which  is  the
  1719. background color that the turtle uses for erasing. Use setpc  to
  1720. select the pen's ink color.
  1721.  
  1722. When the background color is in the range 0 to 15,
  1723.  
  1724.         - setpc 1 selects dark green ink
  1725.         - setpc 2 selects dark red ink
  1726.         - setpc 3 selects dark yellow ink
  1727.  
  1728. When the background color is in the range 16 to 31,
  1729.  
  1730.         - setpc 1 selects bright green ink
  1731.         - setpc 2 selects bright red ink
  1732.         - setpc 3 selects bright yellow ink
  1733.  
  1734. When the background color is in the range 32 to 47,
  1735.  
  1736.         - setpc 1 selects dark cyan ink
  1737.         - setpc 2 selects dark magenta ink
  1738.         - setpc 3 selects dark grey ink
  1739.  
  1740. When the background color is in the range 48 to 63,
  1741.  
  1742.         - setpc 1 selects bright cyan ink
  1743.         - setpc 2 selects bright magenta ink
  1744.         - setpc 3 selects bright white ink
  1745.  
  1746. For  all  background color numbers, setpc 0  selects  background
  1747. color  (erasing)  ink.  When  Dr.  Logo  first  starts  up,  the
  1748. background color is 1, and the pencolor number is 2.
  1749.  
  1750.  
  1751. 4.4.4 Graphic text color
  1752. ------------------------
  1753.  
  1754. "textbg"  controls  the  background color of  the  text  on  the
  1755. graphic screen, both the splitscreen text window and  characters
  1756. typed by turtletext. The background color of graphic text can be
  1757. any  one  of the four colors of the turtle's  current  pen.  For
  1758. example, the following table shows how a textbg command  affects
  1759. the  graphic text when the background of the graphic  screen  is
  1760. set to 1 (blue) and the four pencolors are blue, green, red, and
  1761. yellow.
  1762.  
  1763. Table 4-5. Background color of graphic text
  1764.  
  1765. textbg number   Graphic text background
  1766. -------------   -----------------------
  1767. 0, 4, 8, 12     Blue
  1768. 1, 5, 9, 13     Green
  1769. 2, 6, 10, 14    Red
  1770. 3, 7, 11, 15    Yellow
  1771.  
  1772. Unlike  the  text screen, when you input a number  greater  than
  1773. seven  to  textbg,  graphic  screen  text  characters  are   not
  1774. affected. Characters on the graphic screen cannot blink.
  1775.  
  1776. "textfg"  controls  the foreground color of  graphic  text.  The
  1777. characters  in  the splitscreen text window and  the  turtletext
  1778. characters can be one of the four colors of the turtle's current
  1779. pen. For example, the following table shows how a textfg command
  1780. colors the graphic screen characters when the background of  the
  1781. graphic  screen  is set to 1 (blue) and the four  pencolors  are
  1782. blue, green, red, and yellow.
  1783.  
  1784. Table 4-6. Foreground color of graphic text
  1785.  
  1786. textfg number   Graphic text color
  1787. -------------   ------------------
  1788. 0, 4, 8, 12     Blue
  1789. 1, 5, 9, 13     Green
  1790. 2, 6, 10, 14    Red
  1791. 3, 7, 11, 15    Yellow
  1792.  
  1793.  
  1794. EOF
  1795. DRLRM5.WS4      (= "Dr. Logo Reference Manual", Section 5)
  1796. ----------
  1797.  
  1798. (Retyped by Emmanuel ROCHE.)
  1799.  
  1800.  
  1801. Section 5: Property lists, workspace, and disks
  1802. -----------------------------------------------
  1803.  
  1804. Storage is one of Dr. Logo's most important resources. There are
  1805. two  kinds of storage: temporary storage and permanent  storage.
  1806. When  you  enter  procedure and  variable  definitions  at  your
  1807. keyboard,  they  are  temporarily  stored  in  a  part  of  your
  1808. computer's  memory  called  "the  workspace".  To  record   your
  1809. procedures permanently, you must save them on disk.
  1810.  
  1811. To  help organize your workspace and disk files, Dr.  Logo  lets
  1812. you bundle procedures and variables into packages. Dr. Logo does
  1813. this  by adding system properties to an object's property  list.
  1814. This  section tells how to use property lists and packages,  how
  1815. to  organize  your workspace for best performance,  and  how  to
  1816. create, copy, rename, and erase disk files.
  1817.  
  1818.  
  1819. 5.1 Property lists
  1820. ------------------
  1821.  
  1822. Any  object in the workspace can have a property list. In  fact,
  1823. Dr.  Logo uses property lists to create  variables,  procedures,
  1824. and packages.
  1825.  
  1826. A property list is made up of property pairs. The first  element
  1827. of  a property pair is the property name; the second element  is
  1828. its  value.  You can assign your own properties  to  an  object.
  1829. Property lists make it simple to store and retrieve information,
  1830. as shown in the following example.
  1831.  
  1832.         ?pprop "Kathy "ext 42
  1833.         ?pprop "Meryle "ext 58
  1834.         ?pprop "Ellen "ext 66
  1835.         ?pps
  1836.         Kathy's ext is 42
  1837.         Meryle's ext is 58
  1838.         Ellen's ext is 66
  1839.  
  1840. You  can create whatever property pairs are appropriate to  your
  1841. application.  Dr. Logo adds or removes property pairs  when  you
  1842. use  primitives  identified in the following table. Do  not  use
  1843. system  property names for purposes other than those  listed  in
  1844. the table.
  1845.  
  1846. Table 5-1. Property pairs
  1847.  
  1848. Property name   Primitive       Property value
  1849. -------------   -----------     --------------
  1850.     .APV        make, name,     The value of a global variable
  1851.                 ern, erall,
  1852.                 erns
  1853.  
  1854.     .BUR        bury, unbury    When TRUE, the package is buried
  1855.  
  1856.     .CAT        catch, throw    Catch descriptor
  1857.  
  1858.     .DEF        to, define,     The definition of a procedure
  1859.                 er, erall,
  1860.                 erps
  1861.  
  1862.     .ENL        to, ed          End of a procedure line that is broken by a
  1863.                                 Carriage Return and spaces or tabs.
  1864.  
  1865.     .FMT        to, ed          Beginning of a procedure line that is broken
  1866.                                 by a Carriage Return and spaces or tabs.
  1867.  
  1868.     .FUN                        Identifies an active function, a function in
  1869.                                 the process of being evaluated.
  1870.  
  1871.     .PAK        package         The name of the package to which this object
  1872.                                 belongs.
  1873.  
  1874.     .PAR                        The parameters of an active function
  1875.  
  1876.     .PAU                        Pause
  1877.  
  1878.     .PKG        package         When TRUE, object is a package name
  1879.  
  1880.     .PRM                        Memory location of the primitive
  1881.  
  1882.     .REM                        Remark or comment that follows a semicolon
  1883.  
  1884.     .SPC                        Number of spaces that follow a Carriage
  1885.                                 Return in a broken procedure line.
  1886.  
  1887. When  you use plist to display property lists, you  will  always
  1888. see an .APV pair in a variable name's property list, and a  .DEF
  1889. pair in a procedure's property lists. For example,
  1890.  
  1891.         ?make "flavor "chocolate
  1892.         ?plist "flavor
  1893.         [.APV chocolate]
  1894.         ?to eat.cookie
  1895.         >pr [yum yum!]
  1896.         >end
  1897.         eat.cookie defined
  1898.         ?plist "eat.cookie
  1899.         [.DEF [[] [pr [yum yum!]]]]
  1900.  
  1901. However, you might never see some of the pairs listed above in a
  1902. property list. This is because Dr. Logo puts properties such  as
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913. during the procedure's execution.
  1914.  
  1915.  
  1916. 5.2 Managing your workspace
  1917. ---------------------------
  1918.  
  1919. Your  workspace is the part of your computer's memory  that  Dr.
  1920. Logo allocates for the temporary storage of your procedures  and
  1921. variables.  This  section  tells  how  Dr.  Logo  measures  your
  1922. workspace,  and  how  you  can use  packages  to  organize  your
  1923. workspace.
  1924.  
  1925.  
  1926. 5.2.1 Measuring your workspace
  1927. ------------------------------
  1928.  
  1929. Dr. Logo measures your workspace in nodes. A node is  equivalent
  1930. to  five  bytes, and can hold five characters. In  general,  the
  1931. more  workspace  you  have,  the  better  your  procedures  will
  1932. perform.
  1933.  
  1934. You can check how many free nodes there are in your workspace at
  1935. any time with the "nodes" primitive. Try nodes immediately after
  1936. you  start Dr. Logo, to see the maximum size of your  workspace.
  1937. If you have enough memory in your IBM Personal Computer, you can
  1938. have  over  10,000  nodes at start-up. If you  use  "noprim"  to
  1939. remove  the  poprim  information from  the  workspace,  you  add
  1940. approximately 600 nodes to the maximum size of your workspace.
  1941.  
  1942. You  tie up nodes in your workspace by entering  procedures  and
  1943. other objects at the keyboard, or reading them in from disk with
  1944. "load".  Dr. Logo also adds to the contents of the workspace  by
  1945. making copies of local variables and recursive procedures during
  1946. a procedure's execution.
  1947.  
  1948.  
  1949. 5.2.2 Garbage collection
  1950. ------------------------
  1951.  
  1952. Dr. Logo does not automatically throw out these copies of  local
  1953. variables  and recursively-called procedures after  a  procedure
  1954. finishes execution. However, when there are fewer than 200  free
  1955. nodes in your workspace, a part of Dr. Logo called "the  garbage
  1956. collector" sorts through the workspace and erases any copies  of
  1957. variables  or  procedures that are no longer needed.  You  might
  1958. occasionally  see  an  executing procedure hesitate  for  a  few
  1959. moments while the garbage collector does its work.
  1960.  
  1961. You can call the garbage collector with the "recycle" primitive.
  1962. If you use recycle to clean up the workspace before initiating a
  1963. time-critical  procedure,  you  minimize  the  chance  that  the
  1964. garbage collector will interrupt the execution of the procedure.
  1965. Try  using "nodes" before and after "recycle" to learn how  many
  1966. nodes  are  taken up by the temporary copies  of  variables  and
  1967. procedures.
  1968.  
  1969. The garbage collector uses the stack as it sorts objects in your
  1970. workspace. Although Dr. Logo allocates stack space  dynamically,
  1971. if garbage collection occurs during the execution of a recursive
  1972. procedure  or other situation where the stack is  heavily  used,
  1973. the  garbage  collector can run out of stack  space.  When  this
  1974. occurs,  Dr.  Logo displays a message and  stops  executing  the
  1975. procedure.
  1976.  
  1977. When workspace becomes critical because there are fewer than 400
  1978. free nodes, Dr. Logo displays an exclamation point prompt ("!").
  1979. In  this  situation,  enter  "recycle"  immediately.  If,  after
  1980. "recycle",  you still have fewer than 600 nodes, it is  time  to
  1981. reorganize  your  procedures,  save some of them  on  disk,  and
  1982. remove them from the workspace, to give the remaining procedures
  1983. room  to  execute.  You can use "load"  within  a  procedure  to
  1984. restore saved procedures to the workspace when they are needed.
  1985.  
  1986.  
  1987. 5.2.3 Packages
  1988. --------------
  1989.  
  1990. Packages help you organize your workspace. When you put  related
  1991. procedures  and variables in a package, you can  display,  edit,
  1992. save,  and  erase  those procedures and  variables  as  a  group
  1993. separate from other procedures and variables in the workspace.
  1994.  
  1995. Use  "package"  to create a package or add items to  a  package.
  1996. "package"  requires  two inputs. The first is the  name  of  the
  1997. package. You can give "package" either a name or a list of names
  1998. of  items to be placed in the package as the second  input.  The
  1999. list can contain a mixture of variable and procedure names.  For
  2000. example,
  2001.  
  2002.         ?package "cookies "flavor
  2003.         ?package "cookies [eat.cookies flavor]
  2004.  
  2005. "popkg"  displays the name and contents of each package  defined
  2006. in the workspace, as shown in the following example.
  2007.  
  2008.         ?popkg
  2009.         cookies
  2010.           "flavor
  2011.           eat.cookies
  2012.  
  2013. When  you  input  a  package  name  to  one  of  the   following
  2014. primitives, it takes action only on the procedures and variables
  2015. contained in the package.
  2016.  
  2017.         edall   erall   glist   pops    save
  2018.         edns    erns    poall   pots
  2019.         edps    erps    pons    pps
  2020.  
  2021. If  you do not specify a package name to these primitives,  they
  2022. act on all procedures and variables in the workspace, except for
  2023. those  in buried packages. A buried package is hidden  from  the
  2024. primitives listed above. To bury a package, use "bury", as shown
  2025. in the following example.
  2026.  
  2027.         ?bury "cookies
  2028.         ?popkg
  2029.         cookies is buried
  2030.           "flavor
  2031.           eat.cookies
  2032.  
  2033. Dr. Logo creates and buries packages by adding system properties
  2034. to  property lists. It adds the .PAK property with the  name  of
  2035. the  package to the packaged procedure's or variable's  property
  2036. list.  It  adds  the .PAK property with the value  TRUE  to  the
  2037. package name's property list. When you bury a package, Dr.  Logo
  2038. adds the .BUR property with the value TRUE to the package name's
  2039. property  list.  The  primitives listed above that  can  take  a
  2040. package  name  as input check the property list of  the  package
  2041. name for the .BUR property before taking action.
  2042.  
  2043.  
  2044. 5.3 Drives, disks, and files
  2045. ----------------------------
  2046.  
  2047. When  you  turn  off  your  computer,  all  the  procedures  and
  2048. variables  in your workspace are lost. So, before you turn  your
  2049. computer  off, you must save them on a more permanent medium,  a
  2050. disk.  Dr. Logo stores information on disk in files,  and  gives
  2051. each  file the name you specify. The part of your computer  that
  2052. reads  and  writes  file on a disk is  called  a  "drive".  This
  2053. section gives some background information on drives, disks,  and
  2054. files.
  2055.  
  2056. Many  of  the  primitives that copy and erase  disks  and  files
  2057. display a message that asks you to confirm that you do,  indeed,
  2058. want  to  copy or erase before the primitive proceeds.  This  is
  2059. because it is sometimes too easy to erase or copy over important
  2060. files by mistake. However, such messages make it inconvenient to
  2061. use  these  primitives  from  within  a  procedure.  The  system
  2062. variable NOACK controls whether or not these primitives  display
  2063. a message. Make NOACK TRUE to suppress the messages.
  2064.  
  2065.  
  2066. 5.3.1 Drives
  2067. ------------
  2068.  
  2069. Your IBM Personal Computer has one or two drives. A drive can be
  2070. either single- or double-sided, which means the drive can  write
  2071. on  one  or both sides of the disk. If your drive can  write  on
  2072. both sides of the disk, you can store twice as much  information
  2073. on a disk.
  2074.  
  2075. When  you  first start Dr. Logo, it makes drive A:  the  default
  2076. drive. This means that, until you tell Dr. Logo to do otherwise,
  2077. it looks for information on the disk in drive A:. If you have  a
  2078. single-drive system, drive A: will always be your default drive.
  2079. If you have more than one drive, you can tell Dr. Logo to change
  2080. the default drive with a "setd" command. "defaultd" outputs  the
  2081. name of the default drive in uppercase.
  2082.  
  2083.         ?defaultd
  2084.         A:
  2085.         ?setd "b:
  2086.         ?defaultd
  2087.         B:
  2088.  
  2089. Before  you can save anything on disk, you must put a  formatted
  2090. disk  in a drive. You cannot save information on your  Dr.  Logo
  2091. system disk, so if you have a one-drive system, you must  remove
  2092. the Dr. Logo system disk from the drive and insert a data  disk.
  2093. To  tell  Dr.  Logo that you have inserted  a  new  disk,  enter
  2094. "resetd".  If  you try to save information on  a  newly-inserted
  2095. disk without entering "resetd", Dr. Logo will complain.
  2096.  
  2097.  
  2098. 5.3.2 Disks
  2099. -----------
  2100.  
  2101. Dr.  Logo cannot save information on a disk that is  fresh  from
  2102. the box. The disk must be initialized or formatted to single- or
  2103. double-sided. During the initialization process, Dr. Logo  tests
  2104. and  prepares one or both surfaces of the disk for  future  load
  2105. and  save  operations. Appendix E, "Getting  Started",  and  the
  2106. description of "initd" in Section 6, "References to Primitives",
  2107. both tell how to initialize a disk.
  2108.  
  2109. Dr.  Logo measures the space on your disk in bytes,  not  nodes.
  2110. "spaced"  outputs  the number of free bytes on the disk  in  the
  2111. specified  drive. A single-sided disk can hold 150,000 bytes.  A
  2112. double-sided disk can hold 300,000 bytes.
  2113.  
  2114.  
  2115. 5.3.3 Files
  2116. -----------
  2117.  
  2118. A  file  is a set of related information stored on disk.  A  Dr.
  2119. Logo file contains objects such as procedures and variables with
  2120. their  property  lists.  You can create a  Dr.  Logo  file  with
  2121. "save".  Dr. Logo saves either everything in the  workspace,  or
  2122. just the objects you specify with packages.
  2123.  
  2124. Dr. Logo gives the file the name you specify by writing the name
  2125. in  the  disk's directory. The name you specify  cannot  contain
  2126. more  than eight characters. If you specify a name  longer  than
  2127. eight  characters, Dr. Logo uses the first eight  characters  as
  2128. the name.
  2129.  
  2130. You  can change a file's name with "changef", copy a  file  with
  2131. "copyf", and erase a file with "erf". "getfs" outputs a list  of
  2132. the Dr. Logo file names on the disk in the default or  specified
  2133. drive.  Like  drive  names,  Dr.  Logo  outputs  file  names  in
  2134. uppercase.
  2135.  
  2136. "erf" and "getfs" can accept an ambiguous file name as input. An
  2137. ambiguous  file name can reference more than one file,   because
  2138. it contains a wildcard character and gives Dr. Logo a pattern to
  2139. match. The wildcard character is the question mark ("?"),  which
  2140. must be the last character in the file name.
  2141.  
  2142.         ?getfs
  2143.         [SHAPES PIGLATIN PLAID]
  2144.         ?getfs "p?
  2145.         [PIGLATIN PLAID]
  2146.  
  2147.  
  2148. EOF
  2149.  
  2150.  
  2151.  
  2152.