home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 026.lha / logo / logo.doc < prev    next >
Encoding:
Text File  |  1987-04-02  |  18.5 KB  |  587 lines

  1.     ALOGO Version 1.1  © 1987 by Gerald Owens
  2.  
  3.     Permission is given for free, non-commercial distribution.
  4. This software is TRUE shareware:  If you have contributed something
  5. to the public domain, then you can keep it for free!  Otherwise, it is
  6. requested that you send a tax deductible donation of $5.00 to:
  7.  
  8.                Wycliffe Associates
  9.                Box 2000
  10.                Orange, Ca.   92669-9984
  11.  
  12.  
  13.     Specify that the money is to go for literacy training in less
  14. developed countries, and tell them that "S" sent you.  Be sure to tell
  15. them not to send further information if you don't want it.
  16. Please direct all bug reports and suggestions for improvements to:
  17.  
  18.                Gerald Owens                   Gerald Owens
  19.                C/O William Richardson         C/O Amiga Atlanta
  20.                1599 Council Bluff Dr.         Box 7724
  21.                Atlanta, Ga.  30345            Atlanta, Ga.  30357
  22.  
  23.  
  24. LIMITATIONS
  25.  
  26.      This is just the graphics portions of LOGO.  I have tried to
  27. follow the Apple II LOGO commands as closely as possible, with the
  28. exception of file, editor, and printer related commands.  Any good
  29. book on LOGO should be of help.
  30.  
  31.  
  32. VERSION HISTORY
  33.  
  34. V 1.0       -  Released by accident.  Had bug in linedrawing routine and
  35.                did not clip in approved manner.  Also hogged the machine.
  36.                My apologies to those who got this by accident!!!
  37.  
  38. V 1.1       -  Linedrawing bug fixed.  Clipping done the "right" way,
  39.                but slows it down a bit (better to be safe than sorry, but
  40.                Commodore should work on this). Fixed multitasking problem.
  41.  
  42.  
  43. CAVEATS AND PROBLEM AREAS
  44.  
  45.      A single window is used for the editor, command, and graphics
  46. window.  Wierd things happen to the "turtle" when things get scrolled.
  47.  
  48.      Do not panic!  Repeat, do NOT panic if after successfully executing
  49. a procedure, you re-edit the buffer and find a blank screen!  The
  50. editor is fixed to place the cursor in front of the NEXT statement
  51. to be executed.  If there is an error, the cursor will be in front
  52. of the offending statement.  When a procedure returns, the cursor
  53. is temporarily placed after the END or the OUTPUT statement, so if
  54. the last procedure executed was the last procedure in the editor
  55. buffer, the cursor will be placed after the END statement, and so
  56. may appear alone on a blank screen.  Just press SHIFT-UP ARROW to
  57. get to your code.
  58.  
  59.      The editor is not very good.  I hope that if a later version comes
  60. out, it will be worthy of alternate use as a programmer's editor.
  61.  
  62.      There are no global variables.  All procedure variables are
  63. sort of local/global.  They're global in the sense that they are
  64. accessible outside of the procedure, and local in the sense that
  65. when a procedure is entered, the old value is saved, and when the
  66. procedure is exited, the old value is restored.  Every unique variable
  67. name is placed in a table and all accesses refer to that central
  68. copy, so the scope can be classified as being dynamic.  If you want
  69. global variables, declare a dummy procedure with "local" variables
  70. having the names of the desired global variables.
  71.  
  72.      Procedures and variables are declared using the editor.  They
  73. cannot be declared from the command processor.  When declaring a
  74. procedure, the header (TO <name> <vars>) MUST START on separate lines.
  75.  
  76.  
  77. HOW TO RUN
  78.      ALOGO cannot be executed from the Workbench.  Rather, get into the
  79. CLI and type in:
  80.  
  81. logo
  82.  
  83.            
  84.  
  85. GENERAL COMMANDS
  86.  
  87.    These commands are in addition to the regular ALOGO commands, but
  88. only one command can be typed in on a line.
  89.  
  90. NEW
  91.    Clear the editor buffer.  Will prompt if contents have been
  92.    changed and not saved.
  93.  
  94. LOAD filename
  95.    Clears the editor buffer and loads the text file into the
  96.    editor buffer.  If the previous contents of the buffer was
  97.    changed and not saved, the computer will ask if it is OK
  98.    to delete the file.
  99.    ***WARNING*** Do not use a file name with an embedded blank.
  100.                  Even if it has ""'s around it!
  101.  
  102. SAVE
  103.    Without a file name, saves the editor buffer with the same
  104. name as it was previously loaded or saved under.
  105.  
  106.  
  107. SAVE filename
  108.    Saves the editor buffer under the new name, and records it so that
  109. "SAVE" without a file name saves under that file name.
  110.  
  111.  
  112. EDIT
  113.    Edit the editor buffer.  Press function key 'F1' to excape from the
  114. editor
  115.  
  116.  
  117. LIST
  118.    List the contents of the editor buffer on the screen.  Pressthe Right
  119. Mouse Button to temporarily stop the listing, and release it to
  120. allow the listing to continue.
  121.  
  122.  
  123. LLIST
  124.    Same as LIST, but the contents of the editor buffer are printed
  125. on the printer attached to your Amiga, followed by a Page-Eject.
  126.  
  127.  
  128. FILES
  129.    Same as the AmigaBASIC "FILES" command.  Lists the files in the
  130. current directory on the screen.  Requires that the "DIR" command be
  131. in the "C:" directory.
  132.  
  133.  
  134. QUIT
  135.    Leave logo and return to the operating system.
  136.  
  137.  
  138.  
  139. EDITOR COMMANDS
  140.    Use the cursor keys to move up, down, left, and right.
  141.    Shift up-cursor moves the cursor up 10 lines.
  142.    Shift down-cursor moves the cursor down 10 lines.
  143.    Shift left-cursor move the cursor to the beginning of the line.
  144.    Shift right-cursor moves the cursor to the end of the line.
  145.    The grey DEL key deletes the character under the cursor.
  146.    The BACKSPACE key deletes the character just before the cursor.
  147.    Shift DEL key deletes an entire line.
  148.    Press RETURN to get a new line, or make a line into two lines.  Sorry,
  149.       no way to join two lines together as yet.
  150.    CTRL-Q, CTRL-X and F1 exits from the editor.
  151.  
  152.  
  153.  
  154. EXPRESSIONS
  155.    An element can be any of the following:
  156.  
  157.    a.  A signed integer number (32 bits).  (-235, 447)
  158.    b.  A built-in variable.  (XCOR, YCOR, HEADING, and PENCOLOR.)
  159.    c.  A procedure call.  See the ALOGO command "OUTPUT" on how to
  160.        make a procedure return a value.  (COORD, FAC 4, DDT 77+2 99.)
  161.    d.  A user defined variable.  These start with a ":", followed by
  162.        a letter, and then followed by an optional sequence of letters
  163.        and digits.  (:a , :a1e2b4, :zzz).
  164.    
  165.    (As in the rest of ALOGO, it does not matter if the letters are
  166. in upper or lower case.  Thus, xcor, XCOR, and XcOr are all the same.)
  167.  
  168.    An expression is an element or an algebraic expression using elements.
  169. The following are valid expressions:
  170.  
  171.    5
  172.    :a+5
  173.    3*(:a-7)
  174.    :z/-9+ fac 6    (Procedure call of fac 6.  Result is added to :z/-9)
  175.    :Q % 6          (Remainder of :Q divided by 6)
  176.    -:r             (Negative of the value of :r)
  177.    xpos+4          (The value of built-in variable xpos has 4
  178.                     added to it)
  179.  
  180.    The following are valid operators to use in an expression.  They
  181. all behave the same as they do in AmigaBASIC.
  182.  
  183.    <  -  Less than, for comparing two numbers.
  184.    =  -  Equal to, for comparing two numbers.
  185.    >  -  Greater than, for comparing two numbers.
  186.    AND - Logical AND.
  187.    OR -  Logical OR.
  188.    NOT - Logical NOT.
  189.    *  -  Multiplication
  190.    /  -  Division
  191.    %  -  Modulo.  Same as MOD in AmigaBASIC.
  192.    +  -  Addition
  193.    -  -  Subtraction and negation.
  194.  
  195.    The precedence is as follows (same as for BASIC)
  196.  
  197.    ()'s        (To change the order of the precedence)
  198.    -           (Negation.)
  199.    * , / , %   (Same precedence.  Done left to right.  So 2*3*5/6 is
  200.                 (((2*3)*5)/6). )
  201.    + , -       (Same precedence.  Also done left to right.)
  202.    <,=,>       (Note:  <=,=>, and <> are NOT permitted.)
  203.    NOT
  204.    AND         (Done left to right.)
  205.    OR          (Done left to right.)
  206.  
  207.    Remember that ALOGO does not use anything to separate different
  208. expressions.  This can cause problems when using negation.
  209. As an example, if it is desired to print out 1 and -1 on the
  210. same line, the following command will NOT work:
  211.  
  212.    PRINT [1 -1]
  213.  
  214. It will print out 0, since 1-1 is 0.  To get 1 and -1 to be printed
  215. out separately, one must use:
  216.  
  217.    PRINT [1 (-1)]
  218.  
  219.  
  220.  
  221. ALOGO BUILT-IN VARIABLES
  222.  
  223.    The following are the ALOGO built-in variables.  They hold the values
  224. of different aspects of the drawing pen.
  225.  
  226.  
  227. XCOR
  228.  
  229.    Holds the horizontal coordinate of the pen.  It will normally range
  230. from 0 to 610 in value.  0 is for the far left of the window, and
  231. 610 is for the far right of the window.
  232.  
  233.  
  234. YCOR
  235.  
  236.    Holds the vertical coordinate of the pen.  It will normally range
  237. from 0 to 182 in value, 0 is for the top of the window, and 182 is
  238. for the bottom of the window.
  239.  
  240.  
  241. HEADING
  242.  
  243.    Holds the heading of the pen, which is the direction in which the
  244. pen will move if given a FORWARD or BACK command.  It will range in
  245. value from 0 to 359.
  246.  
  247.  
  248. PENCOLOR
  249.  
  250.    Holds the present drawing color of the pen.  This will be a value
  251. from 0 to 3.  The exact color drawn will depend on the colors set in
  252. the preferences menu.
  253.  
  254.  
  255.  
  256. ALOGO COMMENTS
  257.  
  258.    All ALOGO comments start with a ';', and continue to the end of the
  259. line, and can appear in any line.  For example:
  260.  
  261.          CS PD FD 10 ; this will not be executed >> LT 90 FD 10
  262.  
  263. will draw a line 10 steps long, but will not add the second line going
  264. to the left at the end of the first line.
  265.  
  266.  
  267. ALOGO COMMANDS
  268.  
  269.    The following commands can be typed in at the '>' prompt.  More
  270. than one command can be typed in on the same line.  To stop execution
  271. of the commands or any procedures, press a key on the Amiga keyboard.
  272.  
  273.    The words 'exp', 'exp1', 'exp2', and 'exp3' represent valid expressions
  274. as outlined above.  If none of these appear in the command, then the
  275. command does not take any parameters.
  276.  
  277.    Some of the commands can take a 2 letter abbreviation.  They can also
  278. be typed in in any mix of upper and lower case letters.
  279.  
  280.  
  281. CS
  282. CLEARSCREEN
  283.  
  284.    Clear the screen, put the drawing pen at the center of the screen,
  285. and set the direction to 0 degrees (up).  The pen is left up or down.
  286.  
  287.  
  288. HOME
  289.  
  290.    Put the drawing pen at the center of the screen and set the direction
  291. to 0 degrees (up).  The pen is left either up or down.
  292.  
  293.  
  294. CLEAN
  295.  
  296.    Just clear the screen, without affecting the pen location or whether
  297. the pen is up or down.
  298.  
  299.  
  300. PU
  301. PENUP
  302.  
  303.    Reset the pen so that the pen will not draw lines when moved.
  304.  
  305.  
  306. PD
  307. PENDOWN
  308.  
  309.    Set the Pen so that if the pen is moved, lines will be drawn.
  310.  
  311.  
  312. SETPC exp
  313.  
  314.    Set the pen color to the value of (exp % 4).  Pen colors are dependent
  315. on the Preferences settings, but they will map to the following colors
  316. on all screens:
  317.  
  318.             0 - Background color.
  319.             1 - Color of the letters and the border.
  320.             2 - Color of the Depth Arranger gadget in the upper
  321.                 right corner of the window.
  322.             3 - Color of the cursor.
  323.  
  324.  
  325. SETPOS [exp1 exp2]
  326.  
  327.    Set the pen to be at horizontal coordinate exp1, and vertical coordinate
  328. exp2.  (0,0) is at the upper left corner of the outside of the window, and
  329. (610,182) is at the lower right corner of the window.  If the pen is
  330. down, a line is drawn from the previous position to the new position.
  331. THE "[]"'S AROUND THE TWO EXPRESSIONS ARE MANDATORY.
  332.  
  333.  
  334. DOT [exp1 exp2]
  335.  
  336.    Places a dot of the present pen color at horizontal coordinate exp1
  337. and vertical coordinate exp2.  Exp1 can range from 0 to 610, and exp2
  338. can range from 0 to 182.  THE "[]"'s AROUND THE
  339. TWO EXPRESSIONS ARE MANDATORY.
  340.  
  341.  
  342. SETX exp
  343.  
  344.    Like SETPOS, but sets the horizontal coordinate only, leaving the
  345. vertical coordinate alone.  If the pen is down, then a line is drawn to
  346. the new position from the old position.
  347.  
  348.  
  349. SETY exp
  350.  
  351.    Like SETPOS and SETX, but sets the vertical coordinate only, leaving
  352. the horizontal coordinate alone.  If the pen is down, then a line is drawn
  353. to the new position from the old position.
  354.  
  355.  
  356. FD exp
  357. FORWARD exp
  358.  
  359.    Move in the direction of the heading of the pen (exp) many 'steps'.
  360. (There are 182 steps vertically and 304 horizontally.)  If the pen
  361. is down draw a line.  Note from SETPOS that a step in the horizontal
  362. direction is doubled.  This makes the aspect ratio close to 1:1, so
  363. that the logo statements "FD 10 LT 90 FD 10 LT 90 FD 10 LT 90 FD 10"
  364. forms more of a square than a rectangle.
  365.  
  366.  
  367. BK exp
  368. BACK exp
  369.  
  370.    Move in the opposite direction of the heading of the pen (exp)
  371. many 'steps'.  BK exp is the same as FD -(exp).
  372.  
  373.  
  374. LT exp
  375. LEFT exp
  376.  
  377.    Turn the heading of the pen's heading left (exp) degrees.  Directions
  378. on the screen are:
  379.  
  380.                    left   right
  381.                    <---   --->
  382.                         0
  383.                         ^
  384.                         |
  385.                   270 <-+-> 90
  386.                         |
  387.                         V
  388.                        180
  389.                    <---   --->
  390.                   right   left
  391.  
  392.  
  393. RT exp
  394. RIGHT exp
  395.  
  396.    Turn the heading of the pen's heading right (exp) degrees.  See the
  397. entry for LT and LEFT.   RT exp is the same as LT -(exp)
  398.  
  399.  
  400. SETH exp
  401. SETHEADING
  402.  
  403.    Turn the heading of the pen to the heading of (exp) degrees.  See the
  404. entry for LT and LEFT to see the directions to which the heading will
  405. translate.
  406.  
  407.  
  408. PRINT [ {exp | 'string'} {exp | 'string'} . . . ]
  409.  
  410.     Print the strings or the values of the expressions between the
  411. '[' and the ']'.  There can be as many expressions or as many strings,
  412. in any order, as you wish between the '[' and the ']'.  Strings
  413. *MUST* be surrounded by "'"'s.  The following lines print out
  414. various values.  The results are shown.
  415.  
  416.          PRINT [ 45*7 ' is 315']
  417. result:315  is 315
  418.  
  419.          PRINT ['this' ' is ' 'a' 'test']
  420. result:this is atest                   (put 'a ', rather than 'a', to
  421.                                         avoid this.)
  422.  
  423.          print [1*2 2*2 2*4]
  424. result:2 4 8
  425.  
  426.          PRINT [1*2 '+' 2*3 '=' 2*4]
  427. result:2 +6 =8
  428.  
  429.  
  430. MAKE "var exp
  431.  
  432.    Changes the value of the procedure variable to be the same as exp.
  433. Thus, if the value of :xxt is 17, then executing:
  434.  
  435.    MAKE "xxt :xxt+5
  436.  
  437. will change the value of :xxt to 22.  Note that the ":" is replaced
  438. by a double quote, which is required.  The values of built-in variables
  439. cannot be changed using MAKE.
  440.  
  441.  
  442.  
  443. ALOGO CONTROL STATEMENTS
  444.  
  445.    The following statements affect the flow of control of the program.
  446. Only TO and END can be used in an editor buffer.  All the others can be
  447. typed in directly at the '>' prompt, and in the editor buffer.
  448.  
  449.  
  450. RP exp [stmt stmt ....]
  451. REPEAT exp [stmt stmt ....]
  452.  
  453.    Repeat all the statements between the '[' and the ']' (exp) times.
  454. If exp is less than or equal to 0, the statements between the '[]''s
  455. are not executed.  The following two lines draw the same squares.
  456.  
  457.          CS PD FD 40 LT 90 FD 40 LT 90 FD 40 LT 90 FD 40 LT 90
  458.  
  459.          CS PD REPEAT 4 [FD 40 LT 90]
  460.  
  461.    THE "[]"'s ARE REQUIRED.
  462.  
  463.  
  464. IF exp [true statements] [false statements]
  465. IF exp [true statements]
  466.  
  467.    Tests the value of exp, and if true (not zero) all the statements
  468. between the first set of "[]"'s will be true.  If a second set of
  469. statements are between "[]"'s and are after the first set, they are
  470. skipped.  If the value of exp is false (zero), then the first set
  471. of statements between the "[]"'s is skipped, and the second set of
  472. statements between the second pair of "[]"'s is executed.  If a second
  473. set of statements does not exist (as in the second IF statement), then
  474. there is no error.  There IS an error if the "[]"'s are missing, or
  475. if there is no first set of statements.
  476.  
  477.  
  478. TO procedurename :variable :variable ....
  479. .
  480. .
  481. END
  482.  
  483.    Define a procedure named procedurename, with the variables after it
  484. as parameters.  Procedures cannot be defined directly, but must be typed
  485. into the editor buffer.
  486.  
  487.    TO *MUST* be at the beginning of the line, but END does not have to be on
  488. it's own line.  Failure to do so will cause ALOGO to complain that a
  489. procedure has not been defined.
  490.  
  491.    When the procedurename and parameters are typed in (using the same syntax
  492. as all the built-in commandss), all the statements between the TO and the
  493. END will be executed.
  494.  
  495.    ALOGO variables begin with a ':' followed by a letter, and can be
  496. composed of letters and digits.  ALOGO will not distinguish between
  497. upper and lower case letters, either in the procedure name or the
  498. variable names.
  499.  
  500.    Examples:
  501. ((these are typed into the editor buffer))
  502.  
  503.       to square :x  ;draw a square :x units on a side.
  504.          FD :x LT 90 FD :x LT 90 FD :x LT 90 FD :x LT 90
  505.       end
  506.  
  507.       to multisquare :x1 :turn :x   ;draw :x squares :x1 units on a side
  508.                                     ;turning :turn degrees between each
  509.                                     ;drawn square.
  510.          RP :x [square :x1 LT :turn]  ; this :x will not be confused with
  511.                                       ; the :x in square.  They are
  512.                                       ; different variables.
  513.       end
  514.  
  515. ((these are typed in at the '>' prompt))
  516.  
  517.      >square 50             ;draws a square 50 units on a side
  518.      >multisquare 30 10 36  ;draws 36 squares that are 30 units on a side
  519.                             ;turning 10 degrees between each square
  520.  
  521.    Trying to execute a procedure that is not defined in the editor buffer
  522. will cause ALOGO to complain.
  523.  
  524.    ALOGO procedures are like AmigaBASIC subroutines, and do not normally
  525. return a value.  To make a procedure return a value, so that it can be
  526. used in an expression, see the "OUTPUT" statement.
  527.  
  528.    ALOGO procedures can call other procedures, and can even call
  529. themselves.
  530.  
  531.  
  532. OUTPUT  exp
  533.  
  534.    To make a procedure return a value, use the OUTPUT statement.  The
  535. value returned will be the value of exp.  Some examples are:
  536.  
  537.    ((The following lines are typed into the Editor Buffer))
  538.  
  539.    to sum3 :x :y :z            ;return the sum of :x, :y, :z
  540.       output :x+:y+:z
  541.    end
  542.  
  543.    ((the following lines are typed at the ">" prompt.))
  544.  
  545.    >print [5*sum3 1 2 3]       ;do 5*(1+2+3)
  546. 30
  547.  
  548.    >print [sum3 1 2 3]         ;do 1+2+3
  549. 6
  550.  
  551.    The OUTPUT statement can be used anywhere, even in a set of statements
  552. between "[]"'s in the IF and REPEAT statements.  The execution of the
  553. IF or the REPEAT will be terminated, and the value returned to the
  554. procedure that called the procedure.  It is sort of like the AmigaBASIC
  555. RETURN statement.
  556.  
  557.  
  558. STOP
  559.  
  560.    Like the OUTPUT statement, the STOP statement stops the execution
  561. of a procedure and returns to the procedure that called the original
  562. procedure.  It is exactly like the AmigaBASIC RETURN statement.
  563.  
  564.  
  565. HALT
  566.  
  567.    This is like the AmigaBASIC STOP statement.  It stops the execution
  568. of all procedures and returns to the ">" prompt.  Pressing a key on
  569. the Amiga keyboard will have the same effect.
  570.  
  571.  
  572.  
  573.  
  574. FINAL NOTES
  575.  
  576.      ALOGO V1.0 is written entirely in assembly language, which
  577. accounts partly for its speed and partly for its rough edges, since
  578. most of the programming examples provided by Commodore are oriented
  579. towards "C".  The headers of the procedures are partly compiled into
  580. a table for quick lookup, and are tied directly to the source code
  581. in the editor.  Changing a line in the editor forces this table to
  582. be recompiled.  I could have compiled all the procedures in the
  583. editor buffer in their entirety, but there would have been no direct
  584. connection between errors in the compiled code and where the error
  585. was located in the source.  Thus, in a child-oriented language, I opted
  586. for making the location of errors easy to do.
  587.