Logo Lite Command Reference: ============================ Commands: Forward FD BacK Operations: Sum 3 4 Strings: "foo "bar Numbers: 0, 0.1, 20 Booleans: true false Lists: [1 2 [3 4] 5] Variables: :foo :bar Procedures: Name ip1 ip2... Names: are case insensitive, so NoName = noNAME. use letters a-z, numerals 0-9 and _ (underscore). must begin with a letter. Comments: text after a '#' is ignored. =================== Commands Reference: =================== Screen: ======= Logo begins with a black background and a white pen. ClearScreen Clear graphics screen and place turtle at center with heading 0. CS Same as Home Wipe. Wipe Clear graphics screen. Turtle unchanged. SetBackGround Set background color, name / [rr gg bb] / n (0-15). Default is black. SetBG See SetPenColor for more info on setting colors. Print text and turtle sprite are always white, so best to keep background colors dark. ClearText Clear printed text (not label text). CT ShowTurtle Make turtle visible. ST HideTurtle Make turtle invisible. HT Note: screen border will not indicate if turtle is outside the screen. ResetAll Reset to default values. Note: does not ClearScreen or ClearText. RSA Only needs to be used at the start of a distributed program to ensure consistency. Pen up, color white, width 2 and ShowTurtle. Background color set to black. Fill transparency 50 and fill color white (will appear grey on a black background). Erase user defined varibles and procedures. Turtle Motion: ============== Forward n Move turtle forward n pixels. FD n Back n Move turtle back n pixels. BK n Same as Forward -n. Right d Turn turtle right (clockwise) by angle d degrees. RT d Left d Turn turtle left (counterclockwise) by angle d degrees. LT d Same as Right -d. PenUp Raise pen. Turtle will not draw a line as it moves. PU PenDown Lower pen. Turtle will draw a line as it moves. PD SetHeading h Turn turtle to heading h degrees, measured clockwise from North. SetH h SetX x Move turtle horizontally to coordinate x. SetY y Move turtle vertically to coordinate y. SetPos [x y] Move turtle to coordinate position [x y]. SetPenWidth w Set pen width (thickness) to w. Must be positive. Minimum width 1. SetPW w ArcRight d r Move turtle through a right hand arc of angle d degrees and radius r. ArcR d r If r is 0 then same as Right d. If r is negative then same as ArcLeft d r. ArcLeft d r Move turtle through a left hand arc of angle d degrees and radius r. ArcL d r If r is 0 then same as Left d. If r is negative then same as ArcRight d r. Home Move turtle to center of screen with heading 0. Same as SetPos [0 0] SetH 0. Turtle Static: ============== can be drawn with pen up or down. Circle r Draw a circle of radius r at the turtles position. r must be positive. Same as FD r RT 90 PD ArcR 360 r PU LT 90 BK r. Can be drawn or filled with the pen up. Dot Draw a round dot with pen color and pen width. Sqot Draw a square dot with pen color and pen width. Plot [x y] Draw a round dot at coordinate [x y] with pen color and pen width. Pen Color: ========== There are 3 alternative formats for setting PenColor. Also used for SetBackGround, SetFillColor, Light and Dark. 1/ name 2/ list of [rr gg bb] 3/ number (0-15) Equal Density Colors Black Output [00 00 00] 0 [30 30 30] 8 Blue Output [00 00 99] 1 Orange [99 50 00] 9 Green Output [00 99 00] 2 [15 65 10] 10 Cyan Output [00 99 99] 3 [00 40 70] 11 Red Output [99 00 00] 4 [80 05 05] 12 Magenta Output [99 00 99] 5 Purple [60 30 80] 13 Yellow Output [99 99 00] 6 [70 70 05] 14 White Output [99 99 99] 7 [65 65 65] 15 Grey Output [50 50 50] SetPC name Set pen color to color name. Black, Blue, Green, Cyan, Red, Magenta, Yellow and White. Also Orange, Purple and Grey. You can always define your own color names: eg. to colorname output [rr gg bb] end SetPenColor [rr gg bb] Set pen color to rgb component values, (0-99). Auto clipped. SetPC [rr gg bb] SetPC n Set pen color to color number n, (0-7), or equal density colors (8-15). Use 1+n%7 to avoid Black, or 8+n%7 to avoid last equal density color. Light Output rgb color 50% lighter, eg. SetPC Light Red. Same 3 input formats as SetPenColor, name / [rr gg bb] / n (0-15). Dark Output rgb color 50% darker, eg. SetPC Dark Green. Same 3 input formats as SetPenColor, name / [rr gg bb] / n (0-15). Hue d Output rgb color depending on angle d degrees, eg SetPC Hue 70. Fills: ====== SetFillTrans n Set transparency of fill to n, from 0 (no transparency) to 99 (fully transparent). SetFT n Default is 50. SetFillColor Set fill color. Same 3 input formats as SetPenColor, name / [rr gg bb] / n (0-15). SetFC Default is White (appears grey with default transparency of 50 on a black background). Filled [commands] Fill path described by [commands], using fill color and transparency. Filled paths begin at the start of the described path or any PenDown command, and are filled at the end of the described path or any PenUp command. Self intersecting paths produce filled and unfilled areas (evenodd fill method). Text: ===== Print "foo prints foo Prints text. Use quote to prevent evaluation. PR "foo Each print command starts on a new line. Print ["foo ["bar]] prints foo bar Outer (but not inner) list brackets removed. Print ["rgb "cyan cyan "range 0 "to 99] prints rgb cyan [0 99 99] range 0 to 99. Print ["screen "size SS "x SS "pixels] prints screen size 401 x 401 pixels. Note: Print text is laid over the graphics screen, it can be copied but not edited. To print an empty line, use Print ". To print an empty space, use Print Char 32. Show Same as Print but outer list brackets shown. Also, quotes shown. Label add text to the graphics screen. Same formats as Print above. written horizontally, in the pen color. if PenUp, aligned centrally at turtles position. if PenDown, aligned (left, right, top, bottom), depending on turtle heading and also aligned within the screen area. eg pu setpos [SS SS] pd label "topright Ascii "c Output Unicode of character c. Ascii " is 0. Char n Output character of Unicode n, 32-126. Note: Only use for printing / labelling characters. char 32 is a blank space char 33 to 64 !"#$%&'()*+,-./0123456789:;<=>?@ char 65 to 96 ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_` char 97 to 126 abcdefghijklmnopqrstuvwxyz{|}~ To convert between lower and upper case, subtract or add 32. Arithmetic: =========== all inputs and output are numbers. Sum n m Output sum, n+m. n + m (infix operator) Product n m Output product, n*m. Prod n m n * m (infix operator) Difference n m Output difference, n-m. Diff n m n - m (infix operator) Note: 8 -3 won't work as interpreted as two numbers 8 and -3. Quotient n m Output quotient, n/m. Error if m is 0. Quot n m n / m (infix operator) Modulo n m Output n modulo m, n%m. Error if m is 0. Mod n m n % m (infix operator) Power n m Output n to the power m, n^m. Pow n m Error if both n and m are 0, or, if n is negative and m is not an integer. n ^ m (infix operator) Minus n Output minus n. Remainder n m Output remainder of integer n / integer m. Error if m is 0. Rem n m (not the same as modulo when n is negative) Random n Output a random integer in range 0 to n-1. Error if n is not a positive integer. Rand n eg. Random 4 outputs 0, 1, 2 or 3 Integer num/str Output integer part of n, if n is a number or a string of digits. Int num/str eg. Int "123 outputs 123, so converts a string to an integer. Abs n Output absolute value of n. Exp n Output the value of E (Eulers constant) to power n. Exp 1 is 2.718281828459045. Ln n Output natural logarithm (base e) of n. Error if n is negative or 0. Log10 n Output common logarithm (base 10) of n. Error if n is negative or 0. Round n Output n rounded to nearest integer. Sign n Output -1 if n<0, or 1 if n>0, else 0. Sqrt n Output square root of n. Error if n is negative. Sin n Output sine of n (degrees). Cos n Output cosine of n (degrees). Tan n Output tangent of n (degrees). ArcTan n Output angle (degrees) whose tangent is n. PI Output constant, 3.141592653589793 SqRt2 Output constant, 1.4142135623730951 SS Output constant, 401. Use to indicate a value is dependent on Screen Size. Lists Strings: ============== data types: str -string, num -number, t/f -boolean, lst -list chr -character, single a-z, 0-9 or underscore ind -index, of character in string or thing in list wrd -word, a string, number or boolean thg -thing, a word or list Pick str/lst Output random item from list or character from string. If Emptyp output null. To pick from a group of numbers, put numbers in a list. Count str/lst Output number of items in a list or characters in a string. Emptyp str/lst Output true if list or string is empty ([] or "), else false. Constructs: =========== List thg/lst thg/lst Output list of first thing/list and second thing/list. Sentence thg/lst thg/lst Output flattened list of first thing/list and second thing/list. SE thg/lst thg/lst Word wrd wrd Output string of first word and second word. FPut chr str Output string with char added as first character. FPut thg lst Output list with thing added as first item. LPut chr str Output string with char added as last character. LPut thg lst Output list with thing added as last item. SetItem ind str chr Set the indexed character in a string to char. Index must be an integer between 1 and Count string. SetItem ind lst thg Set the indexed item in a list to thing. Index must be an integer between 1 and Count list. Destructs: ========== First str/lst Output first item in a list, or character in a string. If Emptyp output null. ButFirst str/lst Output list without first item, or string without first character. BF str/lst Last str/lst Output last item in a list, or character in a string. If Emptyp output null. ButLast str/lst Output list without last item, or string without last character. BL str/lst Item ind str Output the indexed character from string. Index must be an integer between 1 and Count. Item ind lst Output the indexed item from list. Index must be an integer between 1 and Count. Remove chr str Output string with every occurrence of char removed. Remove wrd lst Output list with every occurrence of word removed. Library Procedures ================== Capital str Output string with first character capitalised. Convert num b Output number converted to base b. Decrement num Output number-1. Distance [x y] [x y] Output distance between two points. Double num Output 2*number. Evenp num Output true if number is even, else false. Factorial num Output factorial of number. Fibonacci num Output fibonacci of number. Half num Output number/2. HCF m n Output highest common factor of numbers m n. Increment num Output number+1. LCM m n Output lowest common multiple of numbers m n. Least m n Output least of m n. Most m n Output most of m n. Oddp num Output true if number is odd, else false. Polar2Rect ang dist Output rectangular from polar coordinates. Reverse str/lst Output list or string with items or characters in reverse order. Comparison: =========== output false if either input is a list, or words (numbers, strings or booleans) are different data types. Equalp wrd1 wrd2 Output true if wrd1 is the same as wrd2, else false. Case insensitive so "a = "A is true. Note 4 = "4 is false. wrd1 = wrd2 (infix operator) NotEqualp wrd1 wrd2 Output true if wrd1 is not the same as wrd2, else false. wrd1 <> wrd2 (infix operator) Lessp wrd1 wrd2 Output true if wrd1 is less than wrd2 (numerical or alphabetical), else false. wrd1 < wrd2 (infix operator) LessEqualp wrd1 wrd2 Output true if wrd1 is less than or equal to wrd2 (numerical or alphabetical), else false. wrd1 <= wrd2 (infix operator) Greaterp wrd1 wrd2 Output true if wrd1 is greater than wrd2 (numerical or alphabetical), else false. wrd1 > wrd2 (infix operator) GreaterEqualp wrd1 wrd2 Output true if wrd1 is greater than or equal to wrd2 (numerical or alphabetical), else false. wrd1 >= wrd2 (infix operator) Logic: ====== inputs are true or false. And t/f t/f Output true if both inputs are true, else false. Or t/f t/f Output true if either input is true, else false. Not t/f Output true if input is false. Output false if input is true. Loops: ====== For ["name start limit step] [commands] Repeat commands with var_name from start to limit with step size. Name needs preceeding quote. eg For ["a 4 11 2] [print :a] will print 4 6 8 10. Limit can be less than start value. eg For ["a 4 -5 2] [print :a] will print 4 2 0 -2 -4. Sign of step ignored. Repeat n [commands] Repeat [commands] n number of times, n must be a positive integer (or 0). Note: no Forever command, just use a large number. RepCount Within a repeat loop, output the current repetition count, starting at 0. Note: RepCount is only updated at the start of each new repeat loop. Stop Stop the current loop / procedure and return to containing loop / procedure. Output r Stop the current procedure and output result (thing) as an input to the containing loop / procedure. OP r Can only be used within a procedure. Pause Pause and display alert box. Select 'OK' to continue or 'Cancel' to stop. Wait n Wait n milliseconds (approx). Use with a fast speed to create animation effect. Conditionals: ============= If t/f [commands] If true, run [commands]. If false, [commands] not evaluated. IfElse t/f [commands_1] [commands_2] If true, run [commands_1], [commands_2] not evaluated. If false, run [commands_2], [commands_1] not evaluated. Variables: ========== Names are valid strings, (called symbols), must start with a letter and only include letters a-z, digits 0-9 and underscore. Make "name thg Assign value of thing to variable named name. If the name already exists, update its value, else create a new variable. To recall the value of symbol "name, use :name. eg. Make "name :name + 1. Global "name Make "name global in scope, (instead of dynamic). Can only be used within a procedure. Thing "name Output value of "name. Same as :name. (quote to colon) Run "name Run procedure named "name. Note that the procedure cannot take any inputs. (quote to none) General: ======== Date Output list, [mm dd], month and date. Time Output list, [hh mm], hours and minutes. Diagnostics: ============ Command line entries. PrintOutAll Printout variables (name, value), and user defined procedures (name, number of inputs). POA Note: Use ResetAll to clear all memories. Parse command Print out parsed command to help diagnose parser. eg Parse to a pr "b end