Background
jLogo Programming
- Commanding a Turtle
- Pseudocode
- Adding New Commands
- Iteration & Animation
- Hierarchical Structure
- Procedure Inputs
- Operators & Expressions
- Defining Operators
- Words & Sentences
- User Interface Events
- What If? (Predicates)
- Recursion
- Local Variables
- Global Variables
- Word/Sentence Iteration
- Mastermind Project
- Turtles As Actors
- Arrays
- File Input/Output
Java
- A Java Program
- What's a Class?
- Extending Existing Classes
- Types
- Turtle Graphics
- Control Flow
- User Interface Events
Appendices
- Jargon
- What Is TG?
- TG Directives
- jLogo Primitives
- TG Editor
- Java Tables
- Example Programs
- Installation Notes
Updates
- December 13, 2008
- March 7, 2009
- January 6, 2012
- March 15, 2013
- January 20, 2014
- February 13, 2014
- July 29, 2014
- January 18, 2016
- January 29, 2016
Lastly
New TG Features - January 6, 2012
Introduction
Version .0.9.33 of TG has new features that make it easier to use and enhancements that allow you to put together much more interesting applications.
Improved Help
The help directive now supports keywords that are associated with TG's directives, primitive procedures, and editing commands. As a review, prior versions of TG supported a hierarchical-based help. The help command with no input resulted in an overview of the hierarchy being printed. Inputs that have been accepted are:
- "tg" which prints an overview of the TG programming environment,
- categoryName" which prints a list of things that TG can do which fit in the category, and
- item" which prints a description of item.
Now when help is given a keyword, which the help database contains, a list of all things that are tied to the keyword are printed. Figure 1 shows an example of asking for help on io-related stuff.
|
But... which keywords it knows about is limited. If you try to get help on some keyword and none is available, e-mail us your keyword (bfoitGuy at gmail dot com). We will try to improve TG's keyword vocabulary over time.
New Graphics Pixel Stuff
Name | Input(s) | Description | |
COLORSUNDER | Outputs a list of the colors under the turtle's image, one member for each unique color. | ||
GETPIXELS | rectList | Outputs an array of pixel values specified by the input rectangleList, a List of four numbers. The first number is the left-most X edge of the rectangle, the second number is the top Y edge of the rectangle, the third number is the width of the rectangle, and the fourth number is the height of the rectangle, e.g., (sentence :leftX :topY :width :height). | |
SETPIXELS | rectList, pixelArray |
Paints the values of pixels in pixelArray onto the area of the graphics canvas specified by rectList. Pixel values are color numbers. A rectList has the form [leftX, topY, width, height]. | |
SHAPEHEIGHT | Outputs the height of the turtle's shape in pixels, the image for its current heading. | ||
SHAPEPIXELS | Outputs a list containing two members. The first is the number of pixels in each row of the turtle's shape. The second is an array containing all of the pixels that make up the shape's image. | ||
SHAPEWIDTH | Outputs the width of the turtle's shape in pixels, the image for its current heading. | ||
STAMP | Paint the turtle's image onto the graphics canvas. | ||
|
Procedures With a Variable Number of Inputs
A few operators now can accept a variable number of inputs. The most obvious example where this is needed is with the SENTENCE operator. Figure 2 shows how much cleaner this makes programs.
|
In order to supply an operator with a different number of inputs than it is declared to take, you simply surrount the operator name and the inputs with parenthesis. The operators which now can have a variable number of inputs are LIST, PRODUCT, SENTENCE, SUM, and WORD.
Bit Twiddling
Name | Input(s) | Description |
ASHIFT | num1 num2 |
Outputs num1 arithmetic-shifted to the left by num2 bits. If num2 is negative, the shift is to the right with sign extension. The inputs must be integers. |
BITAND | num1 num2 |
Outputs the bitwise AND of its inputs, which must be integers. |
BITNOT | number | Outputs the bitwise NOT of its input, which must be an integer. |
BITOR | num1 num2 |
Outputs the bitwise OR of its inputs, which must be integers. |
BITXOR | num1 num2 |
Outputs the bitwise exclusive OR of its inputs, which must be integers. |
LSHIFT | num1 num2 |
Outputs num1 shifted to the left by num2 bits. If num2 is negative, the shift is to the right with zero fill. The inputs must be integers. |
|
Audio Support
Name | Input(s) | Description | |||||||||||||||||||
LOADCLIP | word clipNumber |
Reads in the .wav (waveform) audio file named word and associates it with clipNumber. This clip can then be played with the PLAYCLIP command. ClipNumber must be in the range 16 - 31. | LOADCLIP "meow.wav 16 | ||||||||||||||||||
PLAYCLIP | clipNumber |
A WAV (waveform) audio clip is played.
|
PLAYCLIP 2 | ||||||||||||||||||
PLAYNOTE | noteNumber length |
A MIDI note number is played for length seconds. In this scheme, middle C
is note number 60 with all other notes relative to this.
Note Numbers Octave | C C# D D# E F F# G G# A A# B -------+--------+--------+----+--------+--------+--------+--- -1 | 0 1 | 2 3 | 4 | 5 6 | 7 8 | 9 10 | 11 0 | 12 13 | 14 15 | 16 | 17 18 | 19 20 | 21 22 | 23 1 | 24 25 | 26 27 | 28 | 29 30 | 31 32 | 33 34 | 35 2 | 36 37 | 38 39 | 40 | 41 42 | 43 44 | 45 46 | 47 3 | 48 49 | 50 51 | 52 | 53 54 | 55 56 | 57 58 | 59 4 | 60 61 | 62 63 | 64 | 65 66 | 67 68 | 69 70 | 71 5 | 72 73 | 74 75 | 76 | 77 78 | 79 80 | 81 82 | 83 6 | 84 85 | 86 87 | 88 | 89 90 | 91 92 | 93 94 | 95 7 | 96 97 | 98 99 |100 |101 102 |103 104 |105 106 |107 8 |108 109 |110 111 |112 |113 114 |115 116 |117 118 |119 9 |120 121 |122 123 |124 |125 126 |127The absolute octave number designations shown here are based on Middle C = C4. |
PLAYNOTE 60 2 |
Turtle-to-Turtle Interaction
For a long time the TELL command has been available for one turtle to get another to perform a list of commands. Now a turtle can ASK another turtle to do something that results in an output to the ASKing turtle.
Name | Input(s) | Description |
ASK | name [operation] |
The turtle named name is passed an operation (an operator and its inputs if any) which it interprets and outputs the result to the asking turtle. |
As an example, look at the operation:
MAKE "otherPosition ASK "otherTurtle [POS]
This sets a variable named otherPosition to the location (the X and Y coordinates) of some other turtle.
Finally...
Lots, and I mean LOTS, of other procedures have been added. They are simply common commands and operations that exist in UCBLogo and I just had not gotten around to adding. You can checkout:
- Details on all TG directives are here (Appendix C).
- Details on all jLogo primitive procedures are here (Appendix D).
- Details on TG editor commands are here (Appendix E).