home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume10 / logo / part06 / logoman.2
Encoding:
Text File  |  1987-06-25  |  35.3 KB  |  867 lines

  1. \f3pendown\f1 \(em Command, no inputs.  Abbreviation: \f3pd\f1
  2. .IN
  3. This command tells the turtle to lower its pen, so that
  4. later commands will draw lines when the turtle moves.
  5. .OU
  6. \f3penerase\f1 \(em Command, no inputs.  Abbreviation: \f3pe\f1
  7. .IN
  8. This command tells the turtle to "lower its eraser", so that lines
  9. previously drawn will be erased when retraced by the turtle.  It
  10. only works with the display turtle.  The commands \f3penup\f1,
  11. \f3pendown\f1, \f3penerase\f1, and \f3penreverse\f1
  12. are mutually exclusive; whichever
  13. was most recently used is the one which affects the turtle.  (Graphics
  14. terminals which cannot selectively erase lines, such as Tektronix
  15. displays, will treat \f3penerase\f1 as \f3pendown\f1.)
  16. .OU
  17. \f3penreverse\f1 \(em Command, no inputs.  Abbreviation: \f3px\f1
  18. .IN
  19. This command tells the display turtle to lower its "reversing pen";
  20. thereafter, when the turtle moves, it turns on any points which were
  21. off, and turns off any points which were on.  The commands \f3penup\f1,
  22. \f3pendown\f1, \f3penerase\f1, and \f3penreverse\f1 are mutually
  23. exclusive; whichever was most recently used is the one which affects the
  24. turtle.  (Note:  Graphics terminals which cannot penreverse will treat
  25. this command as \f3pendown\f1.)
  26. .OU
  27. \f3penmode\f1 \(em Operation, no inputs.
  28. .IN
  29. This operation applies to the floor or the display turtle.  It outputs one
  30. of the words \f3penup\f1, \f3pendown\f1, \f3penerase\f1, or
  31. \f3penreverse\f1, depending on the current state of the turtle's pen.
  32. .OU
  33. \f3lampon\f1 \(em Command, no inputs.  Abbreviation: \f3lon\f1
  34. .IN
  35. This command applies only to the floor turtle; it turns on the
  36. headlamps on the front of the turtle.
  37. .OU
  38. \f3lampoff\f1 \(em Command, no inputs.  Abbreviation: \f3loff\f1
  39. .IN
  40. This command turns off the floor turtle's headlamps.
  41. .OU
  42. \f3hitoot\f1 \(em Command, one input.  Abbreviation: \f3hit\f1
  43. .IN
  44. This command applies only to the floor turtle.  It sounds the
  45. turtle's horn at the higher of its two pitches.  The input is
  46. a number which indicates the number of quarter-seconds to toot
  47. the horn.  Note: large numbers are likely to lead to violent
  48. behavior on the part of other computer users.
  49. .OU
  50. \f3lotoot\f1 \(em Command, one input.  Abbreviation: \f3lot\f1
  51. .IN
  52. This command sounds the floor turtle's horn at the lower of
  53. its two pitches.  The input is the duration of the toot.
  54. .OU
  55. \f3ftouch\f1 \(em Operation (predicate), no inputs.  Abbreviation: \f3fto\f1
  56. .IN
  57. This operation can be used only with the floor turtle.  It has as its
  58. output the word \f3true\f1 if the front of the turtle is touching an
  59. obstacle; otherwise it has the word \f3false\f1 as its output.
  60. .OU
  61. \f3btouch\f1 \(em Operation (predicate), no inputs.  Abbreviation: \f3bto\f1
  62. .IN
  63. This operation can be used only with the floor turtle.  It has as its
  64. output the word \f3true\f1 if the back of the turtle is touching an
  65. obstacle; otherwise it has the word \f3false\f1 as its output.
  66. .OU
  67. \f3ltouch\f1 \(em Operation (predicate), no inputs.  Abbreviation: \f3lto\f1
  68. .IN
  69. This operation can be used only with the floor turtle.  It has as its
  70. output the word \f3true\f1 if the left side of the turtle is touching an
  71. obstacle; otherwise it has the word \f3false\f1 as its output.
  72. .OU
  73. \f3rtouch\f1 \(em Operation (predicate), no inputs.  Abbreviation: \f3rto\f1
  74. .IN
  75. This operation can be used only with the floor turtle.  It has as its
  76. output the word \f3true\f1 if the right side of the turtle is touching an
  77. obstacle; otherwise it has the word \f3false\f1 as its output.
  78. .OU
  79. \f3clearscreen\f1 \(em Command, no inputs.  Abbreviation: \f3cs\f1
  80. .IN
  81. This command applies only to the display turtle.  It erases everything
  82. on the TV screen, and restores the turtle to its initial position and
  83. heading (center of the screen, facing toward the top edge).
  84. .OU
  85. \f3wipeclean\f1 \(em Command, no inputs.  Abbreviation: \f3clean\f1
  86. .IN
  87. This command applies only to the display turtle.  It erases everything
  88. on the TV screen, but does not change the turtle's position or heading.
  89. .OU
  90. \f3fullscreen\f1 \(em Command, no inputs.  Abbreviation: \f3full\f1
  91. .IN
  92. This command applies only to the Atari display turtle.  It eliminates the
  93. use of the bottom four lines of the screen to display the commands
  94. you type; instead, the entire screen is available to show the
  95. picture drawn by the turtle.  However, you can no longer see
  96. what you're typing.  The command may be used after the picture is
  97. already drawn; the part "hidden" by the text at the bottom of
  98. the screen will become visible.  On other displays, \f3fullscreen\f1 and
  99. \f3splitscreen\f1 are equivalent; they make the entire screen available
  100. for graphics, and text appears on the bottom line (Gigis) or superimposed
  101. (ADMs), or somewhere.
  102. .OU
  103. \f3splitscreen\f1 \(em Command, no inputs.  Abbreviation: \f3split\f1
  104. .IN
  105. This command applies only to the Atari display turtle.  It restores the
  106. normal text display at the bottom of the screen, undoing the
  107. effect of the \f3full\f1 command.  On other displays, \f3fullscreen\f1 and
  108. \f3splitscreen\f1 are equivalent; they make the entire screen available
  109. for graphics, with text superimposed in a display-dependent area.
  110. .OU
  111. \f3textscreen\f1 \(em Command, no inputs.  Abbreviation: \f3text\f1
  112. .IN
  113. This command applies only to the display turtle.  It temporarily
  114. removes the turtle display from the screen, making the entire
  115. screen available for text display.  The commands \f3fullscreen\f1 and
  116. \f3splitscreen\f1 will restore the graphics display.  Note:  On the Atari
  117. display, the picture on the screen is remembered, so that when you return
  118. to \f3fullscreen\f1 or \f3splitscreen\f1 mode, the picture returns to the
  119. screen.  On other displays, the picture is forgotten, and you return to
  120. an empty graphics screen.
  121. .OU
  122. \f3hideturtle\f1 \(em Command, no inputs.  Abbreviation: \f3ht\f1
  123. .IN
  124. This command applies only to the display turtle.  It erases the
  125. display of the turtle itself from the screen, so that only the
  126. lines drawn when the turtle moves are visible.  The display is
  127. faster when the turtle is hidden (only slightly faster on the Atari,
  128. but much faster on other terminals).  Also, once a graphics
  129. program is debugged, it may be prettier to watch without the
  130. turtle visible.  (Note:  On the Tektronix display, the turtle is
  131. never visible, because the terminal cannot erase selectively.)
  132. .OU
  133. \f3showturtle\f1 \(em Command, no inputs.  Abbreviation: \f3st\f1
  134. .IN
  135. This command applies only to the display turtle.  It restores
  136. the display of the turtle, after the \f3hideturtle\f1 command
  137. has been used.  (Note:  On the Tektronix display, the turtle is
  138. never visible.)
  139. .OU
  140. \f3shownp\f1 \(em Operation (predicate), no inputs.
  141. .IN
  142. This predicate applies only to the display turtle.  It outputs the word
  143. \f3true\f1 if the turtle is visible on the TV screen, \f3false\f1 otherwise.
  144. .OU
  145. \f3pencolor\f1 \(em Command, one input.  Abbreviation: \f3penc\f1
  146. .IN
  147. This command applies only to the display turtle.  Its effect is different
  148. depending on how each type of terminal supports color.  For the Atari, the
  149. input must be
  150. an integer between 0 and 6.  An input of 0 enters black-and-white
  151. display mode (which is the turtle's initial mode), in which lines
  152. are as thin as possible but there is no control of color.  Any other
  153. input selects color mode, in which lines are twice as thick, so the
  154. effective size of the screen is smaller, but colors can be used.  There
  155. are, in color mode, three possible pen colors, numbered 1 to 3.  There
  156. are 256 possible colors, but only three can be on the screen at a time;
  157. the \f3setcolor\f1 command is used to decide which pen draws in which
  158. actual color.  If the input is 4, 5, or 6, the color is that of pen
  159. 1, 2, or 3, respectively, but lines are drawn in "fill mode": for each
  160. point inked, all points to its right are also inked until a point is
  161. reached which was already inked.  On the Gigi, there is only one mode, and
  162. there is no loss of resolution in using color.  The input must be between
  163. 0 and 7; 0 means black, 7 means white.  The ADM, Tektronix, and Sun displays
  164. do not have multi-color drawing.
  165. .OU
  166. \f3setcolor\f1 \(em Command, two inputs.  Abbreviation: \f3setc\f1
  167. .IN
  168. This command applies only to the Atari display turtle.  The first input
  169. must be an integer between 0 and 3.  If the input is nonzero, the
  170. second input specifies the color for the pen selected by the first
  171. input.  If the first input is zero, the second input specifies the
  172. background color for the color graphics display.  The second input
  173. is either an integer between 0 and 15, which is a color number, or
  174. a list of two integers, in which case the first is a color number
  175. and the second is an intensity number, an integer between 0 and 7.
  176. .OU
  177. \f3setxy\f1 \(em Command, two inputs.
  178. .IN
  179. The two inputs must be numbers.  The turtle is moved to the point
  180. on the screen whose x (horizontal) coordinate is the first input,
  181. and whose y (vertical) coordinate is the second input.  The center
  182. of the screen, where the turtle starts, has both coordinates zero.
  183. If the pen is down, this command draws a line.  This command
  184. applies only to the display turtle.
  185. .OU
  186. \f3setheading\f1 \(em Command, one input.  Abbreviation: \f3seth\f1
  187. .IN
  188. The input must be a number.  The turtle's heading is set to the
  189. input, taken in degrees.  Zero points straight up, as the turtle
  190. starts out; positive headings are clockwise from zero.  This command
  191. applies only to the display turtle.
  192. .OU
  193. \f3towardsxy\f1 \(em Operation, two inputs.
  194. .IN
  195. This operation applies only to the display turtle.  The two inputs must
  196. be numbers, which are the x and y coordinates of a point on the TV
  197. screen.  The output is a number which is the heading to which the turtle
  198. must be set, in order to point towards that point from its current
  199. position.  Note: this operation does not actually move or turn the
  200. turtle.  You must use it as the input to \f3setheading\f1 if that is
  201. what you want.
  202. .OU
  203. \f3xcor\f1 \(em Operation, no inputs.
  204. .IN
  205. The output is the turtle's current x (horizontal) coordinate.  The
  206. operation works only with the display turtle.
  207. .OU
  208. \f3ycor\f1 \(em Operation, no inputs.
  209. .IN
  210. The output is the turtle's current y (vertical) coordinate.  This
  211. operation works only with the display turtle.
  212. .OU
  213. \f3heading\f1 \(em Operation, no inputs.
  214. .IN
  215. The output is the turtle's current heading in degrees.  This operation
  216. works only with the display turtle.
  217. .OU
  218. \f3getpen\f1 \(em Operation, no inputs.
  219. .IN
  220. The output is the turtle's current pen color, or (on the Atari) zero
  221. if in black-and-white
  222. mode.  This operation works only with the display turtle.
  223. .OU
  224. \f3setscrunch\f1 \(em Command, one input.  Abbreviation: \f3setscrun\f1
  225. .IN
  226. This command is used only for display turtles.  The
  227. input must be a number.  The vertical component of turtle motion is
  228. multiplied by this number before each motion is taken.  If squares come
  229. out too wide on your screen, you should increase the number; if too tall,
  230. you should decrease it.  (You can also use \f3setscrunch\f1 to deform the
  231. turtle's motion on purpose, so for example a circle program will draw
  232. an ellipse instead.)  The initial scrunch value depends on the terminal
  233. you are using: for the Atari and the Gigi, it is around 0.8 (your particular
  234. computer center will adjust this for the particular TV monitors you use),
  235. but for the ADM, Tektronix, and Sun, it is 1.0 because these terminals
  236. display the same size steps horizontally and vertically.
  237. .OU
  238. \f3scrunch\f1 \(em Operation, no inputs.
  239. .IN
  240. This operation is used only for display turtles.  It outputs a number, which
  241. is the scrunch factor (or aspect ratio) by which vertical motion is
  242. multiplied before it is displayed.  This number is changed using the
  243. \f3setscrunch\f1 command.
  244. .OU
  245. .ti +5
  246. .UB "Primitive procedures for arithmetic."
  247. Several procedures
  248. are available for arithmetic operations on numbers.  In all
  249. cases, the inputs to these procedures must be numbers, except
  250. as otherwise indicated in the individual descriptions.
  251. .PP
  252. In general, procedures are used in Logo by typing first the name
  253. of the procedure, then its inputs.  This is true of arithmetic
  254. procedures also, e.g.
  255. .EX
  256. sum 3 2
  257. .EC
  258. However, for some arithmetic operations, Logo also recognizes the
  259. more traditional \f2infix\f1 notation, with the operation between
  260. the two inputs:
  261. .EX
  262. 3 + 2
  263. .EC
  264. Be warned, though, that the use of infix forms makes it difficult
  265. for Logo to know how to group operations, unless parentheses are
  266. used.  If you stick to the standard (in Logo) prefix notation,
  267. the grouping is always unambiguous.  For example, the first two of
  268. these three instructions are equivalent, but the third is not:
  269. .EX
  270. if equalp count "hello 5 [print "Yes.]
  271. if (count "hello) = 5 [print "Yes.]
  272. if count "hello = 5 [print "Yes.]
  273. .EC
  274. The reason for the error message produced by the last of those three
  275. instructions is that Logo interprets it as
  276. .EX
  277. if count equalp "hello 5 [print "Yes.]
  278. .EC
  279. That is, the equality test is done first, on the word \f3hello\f1
  280. itself, rather than first taking the count of \f3hello\f1 as
  281. was intended.
  282. .sp 1
  283. \f3sum\f1 \(em Operation, two inputs.  Infix: \f3+\f1
  284. .IN
  285. The output of this procedure is the sum of the two inputs.
  286. .OU
  287. \f3difference\f1 \(em Operation, two inputs.  Abbreviation: \f3diff\f1  Infix: \f3-\f1
  288. .IN
  289. The output of this procedure is the difference of the two inputs.
  290. .OU
  291. \f3product\f1 \(em Operation, two inputs.  Infix: \f3*\f1
  292. .IN
  293. The output of this procedure is the product of the two inputs.
  294. .OU
  295. \f3quotient\f1 \(em Operation, two inputs.  Infix: \f3/\f1
  296. .IN
  297. The output of this procedure is the quotient of the two inputs.
  298. .OU
  299. \f3remainder\f1 \(em Operation, two inputs.  Abbreviation: \f3mod\f1  Infix: \f3\\\f1
  300. .IN
  301. The inputs to this procedure must be integers.  The output is also an
  302. integer, and is the remainder of dividing the first input by the
  303. second.
  304. .OU
  305. \f3maximum\f1 \(em Operation, two inputs.  Abbreviation: \f3max\f1
  306. .IN
  307. The output of this procedure is equal to whichever of the two inputs
  308. is numerically greater.
  309. .OU
  310. \f3minimum\f1 \(em Operation, two inputs.  Abbreviation: \f3min\f1
  311. .IN
  312. The output of this procedure is equal to whichever of the two inputs
  313. is numerically smaller.
  314. .OU
  315. \f3greaterp\f1 \(em Operation (predicate), two inputs.  Infix: \f3>\f1
  316. .IN
  317. The output of this procedure is the word \f3true\f1 if the first input
  318. is numerically strictly greater than the second input.  Otherwise the
  319. output is the word \f3false\f1.
  320. .OU
  321. \f3lessp\f1 \(em Operation (predicate), two inputs.  Infix: \f3<\f1
  322. .IN
  323. The output of this procedure is the word \f3true\f1 if the first input
  324. is numerically strictly less than the second input.  Otherwise the
  325. output is the word \f3false\f1.
  326. .OU
  327. \f3equalp\f1 \(em Operation (predicate), two inputs.  Infix: \f3=\f1
  328. .IN
  329. The two inputs to this procedure may be any Logo objects.  If they
  330. are numbers, then the output is the word \f3true\f1 if they are
  331. numerically equal, \f3false\f1 if they are numerically unequal.  If
  332. either input is not a number, then the output is the same as for the
  333. procedure \f3is\f1: it is \f3true\f1 if the two inputs are identical,
  334. \f3false\f1 if not.  For example, the numbers \f32\f1 and \f32.0\f1 are
  335. numerically equal, but not identical.
  336. .OU
  337. \f3numberp\f1 \(em Operation (predicate), one input.
  338. .IN
  339. The input may be any Logo object.  The output is the word \f3true\f1 if
  340. the input is a number, \f3false\f1 if not.
  341. .OU
  342. \f3zerop\f1 \(em Operation (predicate), one input.
  343. .IN
  344. The input must be a number.  The output is the word \f3true\f1 if the
  345. input is numerically equal to zero, \f3false\f1 otherwise.
  346. .OU
  347. \f3random\f1 \(em Operation, one input.  Abbreviation: \f3rnd\f1
  348. .IN
  349. The input must be a positive integer.  The output is a randomly
  350. selected integer between 0 and one less than the input.
  351. .OU
  352. \f3sqrt\f1 \(em Operation, one input.
  353. .IN
  354. The input must be a nonnegative number.  The output is its square root.
  355. .OU
  356. \f3pow\f1 \(em Operation, two inputs.
  357. .IN
  358. The inputs must be numbers.  If the first is negative, the second must
  359. be an integer.  The output is the first number raised to the power of
  360. the second input.
  361. .OU
  362. \f3sin\f1 \(em Operation, one input.
  363. .IN
  364. The input must be numeric.  The output is the sine of the input, taken
  365. in degrees, not radians.
  366. .OU
  367. \f3cos\f1 \(em Operation, one input.
  368. .IN
  369. The input must be numeric.  The output is the cosine of the input, taken
  370. in degrees, not radians.
  371. .OU
  372. \f3arctan\f1 \(em Operation, one input.  Abbreviation: \f3atan\f1
  373. .IN
  374. The input must be numeric.  The output is the arctangent, in degrees, of
  375. the input.
  376. .OU
  377. .ti +5
  378. .UB "Primitive procedures for conditional execution."
  379. The predicates
  380. (like \f3wordp\f1) which we've mentioned above can be used to carry out
  381. some command only if a condition is met.  The basic command for the
  382. purpose is \f3if\f1:
  383. .sp 1
  384. \f3if\f1 \(em Command or operation, two or three inputs.
  385. .IN
  386. The first input to the \f3if\f1 procedure must be either the word \f3true\f1 or
  387. the word \f3false\f1.  Typically, it is the output from a predicate.  The second
  388. and (optional) third inputs are lists containing instruction lines.  The second
  389. input is executed if the first input is \f3true\f1.  The third input, if any,
  390. is executed if the first input is \f3false\f1:
  391. .sp 1
  392. .nf
  393. \f3to greet :person
  394. if equalp :person [Ronald Reagan] [print [Hi, turkey!]] \\
  395.     [print sentence "Hi, :person]
  396. end\f1
  397. .fi
  398. .sp 1
  399. In that example, the first input to \f3if\f1 is the output from the expression
  400. .br
  401. \f3equalp :person [Ronald Reagan]\f1.
  402. .sp 1
  403. The \f3if\f1 procedure can be used as an operation, producing a value.  In this
  404. case, the third input is required:
  405. .sp 1
  406. .nf
  407. \f3print if equalp :person "Reagan ["Loser] ["Winner]\f1
  408. .fi
  409. .OU
  410. \f3test\f1 \(em Command, one input.
  411. .IN
  412. The input must be the word \f3true\f1 or the word \f3false\f1.  The command
  413. remembers its input for use in a later \f3iftrue\f1 or \f3iffalse\f1
  414. command.  This is an alternative to \f3if\f1 which is useful if several
  415. instructions are to be made conditional on the same condition.  The
  416. remembered truth value is local to the current procedure, if any.
  417. .OU
  418. \f3iftrue\f1 \(em Command, one input.  Abbreviation: \f3ift\f1
  419. .IN
  420. The input must be an instruction list.  It is run if the most recent
  421. \f3test\f1 command saved a \f3true\f1 value.
  422. .OU
  423. \f3iffalse\f1 \(em Command, one input.  Abbreviation: \f3iff\f1
  424. .IN
  425. The input must be an instruction list.  It is run if the most recent
  426. \f3test\f1 command saved a \f3false\f1 value.
  427. .OU
  428. \f3both\f1 \(em Operation (predicate), two inputs.  Abbreviation: \f3and\f1
  429. .IN
  430. The two inputs must both be either \f3true\f1 or \f3false\f1.  The output
  431. is \f3true\f1 if both inputs are \f3true\f1; otherwise the output is
  432. \f3false\f1.
  433. .OU
  434. \f3either\f1 \(em Operation (predicate), two inputs.  Abbreviation: \f3or\f1
  435. .IN
  436. The two inputs must be either \f3true\f1 or \f3false\f1.  The output
  437. is \f3true\f1 if at least one of the inputs is \f3true\f1; otherwise
  438. the output is \f3false\f1.
  439. .OU
  440. \f3not\f1 \(em Operation (predicate), one input.
  441. .IN
  442. The input must be either \f3true\f1 or \f3false\f1.  The output is
  443. \f3true\f1 if the input is \f3false\f1, and vice versa.
  444. .OU
  445. .ti +5
  446. .UB "Primitive procedures for file input and output."
  447. In the Unix
  448. operating system, there are two steps in reading or writing files: first,
  449. the file must be \f2opened\f1, thereby associating a "file descriptor"
  450. (an integer) with the file name; second, the file descriptor is used
  451. to specify the file for each read or write operation.  Logo has
  452. primitive procedures for each of these steps.
  453. .sp 1
  454. \f3openread\f1 \(em Operation, one input.  Abbreviation: \f3openr\f1
  455. .IN
  456. The input to this procedure is a word, which must be a Unix filename.  It
  457. can contain slashes to indicate directory names.  If the file can be
  458. opened for reading, the output from the procedure is a file descriptor,
  459. which should be stored in a variable for use in reading the file.  If the
  460. file cannot be opened, an error results.
  461. .OU
  462. \f3fileread\f1 \(em Operation, one input.  Abbreviation: \f3fird\f1
  463. .IN
  464. The input must be a file descriptor, previously output by \f3openread\f1.  The
  465. procedure reads one line from the file.  The output is the line, in the form
  466. of a list.  (That is, the output is the file line as if enclosed in square
  467. brackets in a program.)  If the end of the file has been reached, the output
  468. is the empty word.  If the file line contains mismatched brackets, trouble
  469. may result.
  470. .OU
  471. \f3fileword\f1 \(em Operation, one input.  Abbreviation: \f3fiwd\f1
  472. .IN
  473. The input must be a file descriptor, open for reading.  The procedure
  474. reads one line from the file.  The output is that line, in the form of
  475. a single word, including spaces and punctuation characters.  If the end
  476. of the file has been reached, the output is the empty list.
  477. .OU
  478. \f3openwrite\f1 \(em Operation, one input.  Abbreviation: \f3openw\f1
  479. .IN
  480. The input must be a Unix filename.  The file is opened for writing
  481. (replacing any previous version), if allowed, and the output is a file
  482. descriptor, for use by file printing commands below.  If the file
  483. cannot be opened, an error results.
  484. .OU
  485. .nf
  486. \f3fileprint\f1 \(em Command, two inputs.  Abbreviation: \f3fip\f1
  487. \f3filetype\f1 \(em Command, two inputs.  Abbreviation: \f3fity\f1
  488. \f3filefprint\f1 \(em Command, two inputs.  Abbreviation: \f3fifp\f1
  489. \f3fileftype\f1 \(em Command, two inputs.  Abbreviation: \f3fifty\f1
  490. .fi
  491. .IN
  492. The first input must be a file descriptor previously output by
  493. \f3openwrite\f1.  The second input is any object.  The second input
  494. is printed (typed, fprinted, ftyped) into the file.
  495. .OU
  496. \f3close\f1 \(em Command, one input.
  497. .IN
  498. The input must be a file descriptor.  The file is closed.  This must
  499. be done when you've finished reading or writing the file.
  500. .sp 1
  501. Sample program:
  502. .sp 1
  503. .nf
  504. \f3make "fd openwrite "outfile
  505. fileprint :fd "Hello.
  506. close :fd\f1
  507. .fi
  508. .sp 1
  509. This will create a file named \f3outfile\f1 containing the word \f3Hello.\f1
  510. .OU
  511. .ti +5
  512. .UB "Primitive procedures for procedure exit."
  513. A procedure written by
  514. a user, in Logo, can be a command or an operation.  If it is an operation,
  515. you must, in the procedure, say what its output should be.  If it is a
  516. command, it can simply stop at the end of the procedure, or you can explicitly
  517. make it stop before the end.
  518. .sp 1
  519. \f3output\f1 \(em Command, one input.  Abbreviation: \f3op\f1
  520. .IN
  521. This command is used in a user procedure which is meant to be an
  522. operation.  The input to this command becomes the output from the
  523. user procedure.  Please don't be confused by the fact that the user
  524. procedure is an operation, while the \f3output\f1 primitive
  525. procedure is a command used in that procedure.  Example:
  526. .sp 1
  527. .nf
  528. \f3to nickname :person
  529. if equalp :person [Peter Parker] [output "Spiderman]
  530. if equalp :person [Lamont Cranston] [output "Shadow]
  531. output first :person
  532. end\f1
  533. .fi
  534. .OU
  535. \f3stop\f1 \(em Command, no inputs.
  536. .IN
  537. This command is used in user procedures which are meant to be
  538. commands.  It stops the user procedure.  (Note that it does not
  539. stop all running procedures.  If user procedure A runs user procedure
  540. B, a \f3stop\f1 command in procedure B returns to procedure A, which
  541. continues after the point where procedure B was invoked.)
  542. .OU
  543. \f3toplevel\f1 \(em Command, no inputs.
  544. .IN
  545. This command stops all running procedures.  The user at the terminal
  546. is prompted to type another command.  This can be used when a user
  547. procedure discovers some error condition and wants to abort the entire
  548. program, for example.
  549. .OU
  550. .ti +5
  551. .UB "Property lists."
  552. It is possible to associate with any name a list
  553. of "properties".  A property list contains property names and property
  554. values.  For example:
  555. .IN
  556. .nf
  557. .sp 1
  558. \f3pprop "bh "firstname "Brian
  559. pprop "bh "lastname "Harvey\f1
  560. .fi
  561. .OU
  562. The form of a property list is
  563. .EX
  564. [name1 val1 name2 val2 name3 val3]
  565. .EC
  566. Although this data structure could be created using other Logo primitives,
  567. special property list primitives are provided because they are faster.  The
  568. property lists do not share storage with Logo variables, so you can change
  569. the value of any property without having to recopy the entire property list
  570. as you would ordinarily.  The following primitives manipulate property lists.
  571. .sp 1
  572. \f3pprop\f1 \(em Command, three inputs.
  573. .IN
  574. The first input, which must be a word, is a name with which a property list
  575. is associated.  The second input, which must be a word, is the name of a
  576. property.  The third input can be any Logo object.  It becomes the value
  577. of the specified property of the specified name.
  578. .OU
  579. \f3gprop\f1 \(em Operation, two inputs.
  580. .IN
  581. Both inputs must be words.  The first is a name, and the second is a
  582. property name.  The output is the value of the indicated property of the
  583. indicated object.  It is not an error if there is no such property;
  584. the output in that case is the empty list.
  585. .OU
  586. \f3remprop\f1 \(em Command, two inputs.
  587. .IN
  588. The inputs must be words, as for \f3gprop\f1.  The specified property
  589. is removed from the specified name.
  590. .OU
  591. \f3plist\f1 \(em Operation, one input.
  592. .IN
  593. The input must be a word, which is a name.  The output is the property
  594. list of the specified name.  Note: the output is actually a copy of the
  595. property list.  The real property list is not a Logo list.  Any later
  596. changes to the properties of the specified name will not change the
  597. list which was output by an earlier \f3plist\f1.
  598. .OU
  599. \f3pps\f1 \(em Command, no inputs.
  600. .IN
  601. All properties of all names are listed on your terminal.
  602. .OU
  603. .ti +5
  604. .UB "Pausing."
  605. When you are debugging a complicated Logo program, it is
  606. very helpful to be able to stop in the middle of a procedure, so that you
  607. can give interactive commands to examine its inputs and other local
  608. variables.  This is different from stopping a procedure, which destroys
  609. its local environment.  There are three ways a procedure can pause:  (1) You
  610. can include the command \f3pause\f1 in the procedure definition, to make the
  611. procedure pause at a particular place you choose in advance; (2) you can
  612. decide to pause a procedure while it is running by typing the system
  613. "interrupt" character (this is control-C at Lincoln-Sudbury but is different
  614. on other systems); or (3) you can arrange for an error in the processing of
  615. the procedure to pause instead of stopping as it usually does.
  616. .PP
  617. Note that when you type the system "quit" character (control-G at
  618. Lincoln-Sudbury) Logo does not pause, but returns to toplevel.  All
  619. information about the local state of your active procedures is lost.
  620. .PP
  621. When you are paused, Logo accepts instructions from your terminal as it
  622. does at toplevel, but local variables can be examined or modified.  To let
  623. you know that you are paused, Logo prompts with the characters "\f3-?\f1"
  624. instead of just "\f3?\f1" as usual.  It is possible to pause within a
  625. procedure within a pause; in this case your prompt is "\f3--?\f1" to
  626. indicate two levels of pause.  This can be continued to higher levels.
  627. .PP
  628. To get out of a pause, there are three things you can do.  You can give the
  629. command \f3toplevel\f1, which stops all pending procedures and returns to
  630. interactive top level.  You can give the command \f3stop\f1 or the command
  631. \f3output\f1 with an input, which will terminate the current procedure
  632. (without or with an output respectively) and return to its calling
  633. procedure.  Or you can give the command \f3continue\f1, which will resume
  634. the procedure at the point where you paused.
  635. .sp 1
  636. \f3pause\f1 \(em Command, no inputs.
  637. .IN
  638. This command is meaningful only within a procedure.  It causes a pause.
  639. .OU
  640. \f3continue\f1 \(em Command, no inputs.  Abbreviation: \f3co\f1
  641. .IN
  642. This command is meaningful only when typed during an interactive pause.  It
  643. continues the current procedure from where it was paused.
  644. .OU
  645. \f3errpause\f1 \(em Command, no inputs.
  646. .IN
  647. This command tells Logo that any errors which happen during procedure
  648. execution from now on should cause a pause, rather than a return to
  649. toplevel.
  650. .OU
  651. \f3errquit\f1 \(em Command, no inputs.
  652. .IN
  653. This command tells Logo that any errors which happen during procedure
  654. execution from now on should return to toplevel, rather than pausing.  This
  655. is the initial state of affairs when you start Logo.
  656. .OU
  657. \f3setqpause\f1 \(em Command, no inputs.
  658. .IN
  659. This command tells Logo that from now on, the system quit character should
  660. pause, and the system interrupt character should return to toplevel.  This
  661. is the reverse of the usual interpretation.  This command is provided for
  662. people whose systems or keyboards make one of these characters easier to
  663. type than the other.  In particular, under Eunice there is only an interrupt
  664. character, not a quit character.
  665. .OU
  666. \f3setipause\f1 \(em Command, no inputs.
  667. .IN
  668. This command tells Logo that from now on, the system interrupt character
  669. should pause, and the system quit character should return to toplevel.  This
  670. is the initial state of affairs when you start Logo.
  671. .OU
  672. .ti +5
  673. .UB "Miscellaneous primitives."
  674. The remaining primitives are one
  675. of a kind, or very obscure, or both.
  676. .sp 1
  677. \f3goodbye\f1 \(em Command, no inputs.  Abbreviation: \f3bye\f1
  678. .IN
  679. This command is used to leave Logo.  It is the only way out, unless
  680. there is a bug somewhere.
  681. .OU
  682. \f3thing\f1 \(em Operation, one input.
  683. .IN
  684. The input must be a word, and must be the name of a variable.  The
  685. output is the value of the variable.  These are equivalent:
  686. .sp 1
  687. .nf
  688. \f3:foo
  689. thing "foo\f1
  690. .fi
  691. .OU
  692. \f3namep\f1 \(em Operation (predicate), one input.
  693. .IN
  694. The input must be a word.  The output is \f3true\f1 if that word is the
  695. name of a variable which has a value assigned to it, \f3false\f1 otherwise.
  696. .OU
  697. \f3wait\f1 \(em Command, one input.
  698. .IN
  699. The input must be a positive integer.  Logo waits that many seconds
  700. before continuing.
  701. .OU
  702. \f3trace\f1 \(em Command, no inputs.
  703. .IN
  704. This command is used for debugging your Logo programs.  After you use
  705. this command, every time a user-defined procedure starts or stops, a
  706. message is typed at your terminal naming the procedure and its inputs
  707. or its output, if any.  The message is indented according to the depth
  708. in procedure calls.
  709. .OU
  710. \f3untrace\f1 \(em Command, no inputs.
  711. .IN
  712. This command turns off the trace messages started by the \f3trace\f1
  713. command.
  714. .OU
  715. \f3unix\f1 \(em Command, one input.
  716. .IN
  717. The input must be a Unix shell command, which is carried out in a
  718. forked shell.  (/bin/sh is used, not csh.)  Example:
  719. .sp 1
  720. .nf
  721. \f3to whois :user
  722. unix (sentence "grep (word "'^ :user ":') "/etc/inquir)
  723. end\f1
  724. .fi
  725. .OU
  726. \f3run\f1 \(em Command or operation, one input.
  727. .IN
  728. The input must be a list, containing a Logo instruction line.  The list is
  729. run as if you typed it directly to Logo.  Example:
  730. .sp 1
  731. .nf
  732. \f3to while :condition :cmd
  733. if not run :condition [stop]
  734. run :cmd
  735. while :condition :cmd
  736. end
  737. .sp 1
  738. make "number 1
  739. while [:number < 5] [print :number; make "number :number+1]\f1
  740. .fi
  741. .sp 1
  742. The \f3run\f1 procedure can be used as an operation, if its input is a Logo
  743. expression which produces a value, instead of a complete instruction:
  744. .sp 1
  745. \f3print run [sum 2 3]\f1
  746. .OU
  747. \f3repeat\f1 \(em Command, two inputs.
  748. .IN
  749. The first input must be a positive number.  The second is an instruction list,
  750. as for the \f3run\f1 command.  The list is run repeatedly, the number of times
  751. specified by the first input:
  752. .sp 1
  753. \f3repeat 5 [print "hello]\f1
  754. .OU
  755. \f3repcount\f1 \(em Operation, no inputs.
  756. .IN
  757. This operation may be used only within the range of a \f3repeat\f1 command.  It
  758. outputs the number of repetitions which have been done, including the current
  759. one.  That is, it outputs 1 the first time through, 2 the second time, and
  760. so on.
  761. .OU
  762. \f3break\f1 \(em Command, no inputs.
  763. .IN
  764. This command is only meaningful within the range of an \f3if\f1 command
  765. within the range of a \f3repeat\f1 command.  It terminates the repeat
  766. immediately.  If used in other contexts, the results may be strange.
  767. .OU
  768. \f3cbreak\f1 \(em Command, one input.
  769. .IN
  770. The input must be either the word \f3on\f1 or the word \f3off\f1.  If
  771. the input is \f3on\f1, your terminal is placed in cbreak mode, which
  772. means that what you type is made available to your program every
  773. character, rather than every line.  This must be done before the
  774. \f3readchar\f1 procedure, below, will work.  This facility is good for
  775. writing video game programs or text editors.  While in cbreak mode, echo
  776. is turned off also.
  777. .OU
  778. \f3readchar\f1 \(em Operation, no inputs.  Abbreviation: \f3rc\f1
  779. .IN
  780. This operation waits for you to type a single character at your terminal.  The
  781. output is a word containing only that character.  This works only if you
  782. have turned on cbreak mode; see above.
  783. .OU
  784. \f3keyp\f1 \(em Operation (predicate), no inputs.
  785. .IN
  786. This procedure outputs \f3true\f1 if there is a character waiting to
  787. be read from the terminal, if you are in cbreak mode.  If not, it
  788. outputs \f3true\f1 if there is an entire line waiting to be read.
  789. .OU
  790. \f3cleartext\f1 \(em Command, no inputs.  Abbreviation: \f3ct\f1
  791. .IN
  792. This command clears the screen.  It uses termlib to be terminal-independent.
  793. .OU
  794. \f3setcursorxy\f1 \(em Command, two inputs.  Abbreviation: \f3setcxy\f1
  795. .IN
  796. This command positions the terminal cursor to the column and row specified
  797. by the two inputs, which must be integers.  It uses termlib to support a
  798. wide variety of terminals, but not every terminal is capable of cursor
  799. addressing.  There is a library procedure setcursor that takes one input,
  800. a list of two numbers, column and row.
  801. .OU
  802. \f3oflush\f1 \(em Command, no inputs.
  803. .IN
  804. Normally, when you tell Logo to print something, the printing is not done
  805. right away.  Instead, Logo remembers everything you tell it to print, and the
  806. printing is done all at once the next time Logo is waiting for you to type
  807. something.  This arrangement makes Logo much faster than it would be if
  808. everything were printed immediately.  The \f3oflush\f1 command tells Logo to
  809. print whatever you've previously asked for right away, without waiting.
  810. .OU
  811. \f3help\f1 \(em Command, no inputs.
  812. .IN
  813. This command types at your terminal a brief message about Logo and
  814. how to use it.
  815. .OU
  816. \f3describe\f1 \(em Command, one input.
  817. .IN
  818. The input must be the name of a Logo primitive procedure.  A brief
  819. explanation of that primitive is typed at your terminal.
  820. .OU
  821. \f3go\f1 \(em Command, one input.
  822. .IN
  823. This command can be used only inside a procedure.  The input must be a
  824. number.  The same number must appear at the beginning of some line in
  825. the same procedure.  (This line number is otherwise ignored.)
  826. The next command executed will be
  827. the one on the indicated line in the definition.  Note: there is always
  828. a better way to do it.  If you have previously programmed in BASIC, your
  829. only hope of ever really learning how to program computers is NEVER EVER
  830. to use the \f3go\f1 command!
  831. .OU
  832. \f3debquit\f1 \(em Command, no inputs.
  833. .IN
  834. This command is meant to be used only for debugging Logo itself.  It is
  835. explained here only for completeness.  After this command is used, the
  836. QUIT signal is not caught by Logo, so it will cause a core dump.
  837. .OU
  838. \f3memtrace\f1 \(em Command, no inputs.
  839. .IN
  840. This command is meant to be used only for debugging Logo itself.  It is
  841. explained here only for completeness.  After this command is used, every
  842. allocation or deallocation of memory, and every character parsed by the
  843. interpreter, types an incomprehensible message at your terminal.
  844. .OU
  845. \f3yaccdebug\f1 \(em Command, no inputs.
  846. .IN
  847. This command is meant to be used only for debugging Logo itself.  It is
  848. explained here only for completeness.  After this command is used, every
  849. state transition in the yacc parser types an incomprehensible message
  850. at your terminal.
  851. .OU
  852. .ti +5
  853. .UB "The Logo library."
  854. The directory /usr/lib/logo contains Logo
  855. procedures which are available to all users.  They are not listed by
  856. \f3pots\f1, but can be thought of as pseudo-primitives which happen to
  857. be written in Logo.  Some of these procedures are only useful in conjunction
  858. with the teaching units used in Introduction to Computers, but others are
  859. generally useful.  This manual does not fully document the Logo
  860. library, because it changes
  861. too often.  Look through the /usr/lib/logo directory yourself if you want.
  862. The procedures \f3setcursor\f1,
  863. \f3listp\f1, \f3home\f1, \f3pos\f1, \f3setpos\f1, \f3towards\f1, \f3setx\f1,
  864. and \f3sety\f1 in the library are provided for partial compatibility with
  865. Apple Logo.
  866.  
  867.