BERKELEY LOGO 6.2

Short Table of Contents

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

Top


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction


Next: , Previous: , Up: INTRODUCTION   [Contents][Index]

1.1 Overview

Copyright © 1993 by the Regents of the University of California

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.

This is a program that is still being written. Many things are missing, including adequate documentation. This manual assumes that you already know how to program in Logo, and merely presents the details of this new implementation.

Read Computer Science Logo Style, Volume 1: Symbolic Computing by Brian Harvey (MIT Press, 1997) for a tutorial on Logo programming with emphasis on symbolic computation.

Here are the special features of this dialect of Logo:


Source file compatible among Unix, DOS, Windows, and Mac platforms.

Random-access arrays.

Variable number of inputs to user-defined procedures.

Mutators for list structure (dangerous).

Pause on error, and other improvements to error handling.

Comments and continuation lines; formatting is preserved when
procedure definitions are saved or edited.

Terrapin-style tokenization (e.g., [2+3] is a list with one member)
but LCSI-style syntax (no special forms except TO).  The best of
both worlds.

First-class instruction and expression templates (see APPLY).

Macros.

Features not found in Berkeley Logo include robotics, music, animation, parallelism, and multimedia. For those, buy a commercial version.


Next: , Previous: , Up: INTRODUCTION   [Contents][Index]

1.2 Getter/Setter Variable Syntax

Logo distinguishes procedures from variables. A procedure is a set of instructions to carry out some computation; a variable is a named container that holds a data value such as a number, word, list, or array.

In traditional Logo syntax, a non-numeric word typed without punctuation represents a request to invoke the procedure named by that word. A word typed with a preceding quotation mark represents the word itself. For example, in the instruction

	PRINT FIRST "WORD

the procedures named FIRST and PRINT are invoked, but the procedure named WORD is not invoked; the word W-O-R-D is the input to FIRST.

What about variables? There are two things one can do with a variable: give it a value, and find out its value. To give a variable a value, Logo provides the primitive procedure MAKE, which requires two inputs: the name of the variable and the new value to be assigned. The first input, the name of the variable, is just a word, and if (as is almost always the case) the programmer wants to assign a value to a specific variable whose name is known in advance, that input is quoted, just as any known specific word would be:

	MAKE "MY.VAR FIRST "WORD

gives the variable named MY.VAR the value W (the first letter of WORD).

To find the value of a variable, Logo provides the primitive procedure THING, which takes a variable name as its input, and outputs the value of the accessible variable with that name. Thus

	PRINT THING "MY.VAR

will print W (supposing the MAKE above has been done). Since finding the value of a specific, known variable name is such a common operation, Logo also provides an abbreviated notation that combines THING with quote:

	PRINT :MY.VAR

The colon (which Logo old-timers pronounce "dots") replaces THING and " in the earlier version of the instruction.

Newcomers to Logo often complain about the need for all this punctuation. In particular, Logo programmers who learned about dots and quotes without also learning about THING wonder why an instruction such as

	MAKE "NEW.VAR :OLD.VAR

uses two different punctuation marks to identify the two variables. (Having read the paragraphs above, you will understand that actually both variable names are quoted, but the procedure THING is invoked to find the value of OLD.VAR, since it’s that value, not OLD.VAR’s name, that MAKE needs to know. It wouldn’t make sense to ask for THING of NEW.VAR, since we haven’t given NEW.VAR a value yet.)

Although Logo’s punctuation rules make sense once understood, they do form a barrier to entry for the Logo beginner. Why, then, couldn’t Logo be designed so that an unpunctuated word would represent a procedure if there is a procedure by that name, or a variable if there is a variable by that name? Then we could say

	PRINT MY.VAR

and Logo would realize that MY.VAR is the name of a variable, not of a procedure. The traditional reason not to use this convention is that Logo allows the same word to name a procedure and a variable at the same time. This is most often important for words that name data types, as in the following procedure:

	TO PLURAL :WORD
	OUTPUT WORD :WORD "S
	END

Here the name WORD is a natural choice for the input to PLURAL, since it describes the kind of input that PLURAL expects. Within the procedure, we use WORD to represent Logo’s primitive procedure that combines two input words to form a new, longer word; we use :WORD to represent the variable containing the input, whatever actual word is given when PLURAL is invoked.

	? PRINT PLURAL "COMPUTER
	COMPUTERS

However, if a Logo instruction includes an unquoted word that is not the name of a procedure, Logo could look for a variable of that name instead. This would allow a "punctuationless" Logo, provided that users who want to work without colons for variables choose variable names that are not also procedure names.

What about assigning a value to a variable? Could we do without the quotation mark on MAKE’s first input? Alas, no. Although the first input to MAKE is usually a constant, known variable name, sometimes it isn’t, as in this example:

	TO INCREMENT :VAR
	MAKE :VAR (THING :VAR)+1	; Note: it's not "VAR here!
	END

	? MAKE "X 5
	? INCREMENT "X
	? PRINT :X
	6

The procedure INCREMENT takes a variable name as its input and changes the value of that variable. In this example there are two variables; the variable whose name is VAR, and whose value is the word X; and the variable whose name is X and whose value changes from 5 to 6. Suppose we changed the behavior of MAKE so that it took the word after MAKE as the name of the variable to change; we would be unable to write INCREMENT:

	TO INCREMENT :VAR		; nonworking!
	MAKE VAR (THING VAR)+1
	END

This would assign a new value to VAR, not to X.

What we can do is to allow an alternative to MAKE, a "setter" procedure for a particular variable. The notation will be

	? SETFOO 7
	? PRINT FOO
	7

SETFOO is a "setter procedure" that takes one input (in this case the input 7) and assigns its value to the variable named FOO.

Berkeley Logo allows users to choose either the traditional notation, in which case the same name can be used both for a procedure and for a variable, or the getter/setter notation, in which variable FOO is set with SETFOO and examined with FOO, but the same name can’t be used for procedure and variable.

Here is how this choice is allowed: Berkeley Logo uses traditional notation, with procedures distinct from variables. However, if there is a variable named AllowGetSet whose value is TRUE (which there is, by default, when Logo starts up), then if a Logo instruction refers to a nonexistent procedure (so that the error message "I don’t know how to ..." would result), Logo tries the following two steps:

	1.  If the name is at least four characters long, and the first three
	characters are the letters SET (upper or lower case), and if the name
	is followed in the instruction by another value, and if the name
	without the SET is the name of a variable that already exists, then
	Logo will invoke MAKE with its first input being the name without the
	SET, and its second input being the following value.

	2.  If step 1’s conditions are not met, but the name is
	the name of an accessible variable, then Logo will invoke
	THING with that name as input, to find the variable’s value.

Step 1 requires that the variable already exist so that misspellings of names of SETxxx primitives (e.g., SETHEADING) will still be caught, instead of silently creating a new variable. The command GLOBAL can be used to create a variable without giving it a value.

One final point: The TO command in Logo has always been a special case; the rest of the line starting with TO is not evaluated as ordinary Logo expressions are. In particular, the colons used to mark the names of inputs to the procedure do not cause THING to be invoked. They are merely mnemonic aids, reminding the Logo user that these words are names of variables. (Arguably, this nonstantard behavior of TO adds to Logo beginners’ confusion about colons.) To a programmer using colonless variable references, the colons in the TO line are unnecessary and meaningless. Berkeley Logo therefore makes the colons optional:

	TO FOO :IN1 :IN2

and

	TO FOO IN1 IN2

are both allowed.


Next: , Previous: , Up: INTRODUCTION   [Contents][Index]

1.3 Entering and Leaving Logo

The process to start Logo depends on your operating system:

Unix:

Type the word logo to the shell. (The directory in which you’ve installed Logo must be in your path.)

DOS:

Change directories to the one containing Logo (probably C:\UCBLOGO). Then type UCBLOGO for the large memory version, or BL for the 640K version.

Mac:

Double-click on the LOGO icon within the "UCB Logo" folder.

Windows:

Double-click on the UCBWLOGO icon in the UCBLOGO folder.

To leave Logo, enter the command bye.

On startup, Logo looks for a file named startup.lg in the system Logo library and, if found, loads it. Then it looks for startup.lg in the user’s home directory, or the current directory, depending on the operating system, and loads that. These startup files can be used to predefine procedures, e.g., to provide non-English names for primitive procedures.

Under Unix, DOS, or Windows, if you include one or more filenames on the command line when starting Logo, those files will be loaded before the interpreter starts reading commands from your terminal. If you load a file that executes some program that includes a bye command, Logo will run that program and exit. You can therefore write standalone programs in Logo and run them with shell/batch scripts. To support this technique, Logo does not print its usual welcoming and parting messages if you give file arguments to the logo command.

If a command line argument is just a hyphen, then all command line arguments after the hyphen are not taken as filenames, but are instead collected in a list, one word per argument; the buried variable COMMAND.LINE contains that list of arguments, or the empty list if there are none. On my Linux system, if the first line of an executable shell script is #!/usr/local/bin/logo - (note the hyphen) then the script can be given command line arguments and they all end up in :COMMAND.LINE along with the script’s path. Experiment.

If you type your interrupt character (see table below) Logo will stop what it’s doing and return to top-level, as if you did THROW "TOPLEVEL. If you type your quit character Logo will pause as if you did PAUSE.

            wxWidgets      Unix       DOS/Windows     Mac Classic

toplevel      alt-S   usually ctrl-C    ctrl-Q     command-. (period)

pause         alt-P   usually ctrl-\    ctrl-W     command-, (comma)

If you have an environment variable called LOGOLIB whose value is the name of a directory, then Logo will use that directory instead of the default library. If you invoke a procedure that has not been defined, Logo first looks for a file in the current directory named proc.lg where proc is the procedure name in lower case letters. If such a file exists, Logo loads that file. If the missing procedure is still undefined, or if there is no such file, Logo then looks in the library directory for a file named proc (no .lg) and, if it exists, loads it. If neither file contains a definition for the procedure, then Logo signals an error. Several procedures that are primitive in most versions of Logo are included in the default library, so if you use a different library you may want to include some or all of the default library in it.


Previous: , Up: INTRODUCTION   [Contents][Index]

1.4 Tokenization

Names of procedures, variables, and property lists are case-insensitive. So are the special words END, TRUE, and FALSE. Case of letters is preserved in everything you type, however.

Within square brackets, words are delimited only by spaces and square brackets. [2+3] is a list containing one word. Note, however, that the Logo primitives that interpret such a list as a Logo instruction or expression (RUN, IF, etc.) reparse the list as if it had not been typed inside brackets.

After a quotation mark outside square brackets, a word is delimited by a space, a square bracket, or a parenthesis.

A word not after a quotation mark or inside square brackets is delimited by a space, a bracket, a parenthesis, or an infix operator +-*/=<>. Note that words following colons are in this category. Note that quote and colon are not delimiters. Each infix operator character is a word in itself, except that the two-character sequences <=, >=, and <> (the latter meaning not-equal) with no intervening space are recognized as a single word.

A word consisting of a question mark followed by a number (e.g., ?37), when runparsed (i.e., where a procedure name is expected), is treated as if it were the sequence

( ? 37 )

making the number an input to the ? procedure. (See the discussion of templates, below.) This special treatment does not apply to words read as data, to words with a non-number following the question mark, or if the question mark is backslashed.

A line (an instruction line or one read by READLIST or READWORD) can be continued onto the following line if its last character is a tilde (~). READWORD preserves the tilde and the newline; READLIST does not.

Lines read with READRAWLINE are never continued.

An instruction line or a line read by READLIST (but not by READWORD) is automatically continued to the next line, as if ended with a tilde, if there are unmatched brackets, parentheses, braces, or vertical bars pending. However, it’s an error if the continuation line contains only the word END; this is to prevent runaway procedure definitions. Lines explicitly continued with a tilde avoid this restriction.

If a line being typed interactively on the keyboard is continued, either with a tilde or automatically, Logo will display a tilde as a prompt character for the continuation line.

A semicolon begins a comment in an instruction line. Logo ignores characters from the semicolon to the end of the line. A tilde as the last character still indicates a continuation line, but not a continuation of the comment. For example, typing the instruction

print "abc;comment ~
def

will print the word abcdef. Semicolon has no special meaning in data lines read by READWORD or READLIST, but such a line can later be reparsed using RUNPARSE and then comments will be recognized.

The two-character sequence #! at the beginning of a line also starts a comment. Unix users can therefore write a file containing Logo commands, starting with the line

#! /usr/local/bin/logo

(or wherever your Logo executable lives) and the file will be executable directly from the shell.

To include an otherwise delimiting character (including semicolon or tilde) in a word, precede it with backslash (\). If the last character of a line is a backslash, then the newline character following the backslash will be part of the last word on the line, and the line continues onto the following line. To include a backslash in a word, use \\. If the combination backslash-newline is entered at the terminal, Logo will issue a backslash as a prompt character for the continuation line. All of this applies to data lines read with READWORD or READLIST as well as to instruction lines.

A line read with READRAWLINE has no special quoting mechanism; both backslash and vertical bar (described below) are just ordinary characters.

An alternative notation to include otherwise delimiting characters in words is to enclose a group of characters in vertical bars. All characters between vertical bars are treated as if they were letters. In data read with READWORD the vertical bars are preserved in the resulting word. In data read with READLIST (or resulting from a PARSE or RUNPARSE of a word) the vertical bars do not appear explicitly; all potentially delimiting characters (including spaces, brackets, parentheses, and infix operators) appear unmarked, but tokenized as though they were letters. Within vertical bars, backslash may still be used; the only characters that must be backslashed in this context are backslash and vertical bar themselves.

Characters entered between vertical bars are forever special, even if the word or list containing them is later reparsed with PARSE or RUNPARSE. Characters typed after a backslash are treated somewhat differently: When a quoted word containing a backslashed character is runparsed, the backslashed character loses its special quality and acts thereafter as if typed normally. This distinction is important only if you are building a Logo expression out of parts, to be RUN later, and want to use parentheses. For example,

PRINT RUN (SE "\( 2 "+ 3 "\))

will print 5, but

RUN (SE "MAKE ""|(| 2)

will create a variable whose name is open-parenthesis. (Each example would fail if vertical bars and backslashes were interchanged.)

A normally delimiting character entered within vertical bars is EQUALP to the same character without the vertical bars, but can be distinguished by the VBARREDP predicate. (However, VBARREDP returns TRUE only for characters for which special treatment is necessary: whitespace, parentheses, brackets, infix operators, backslash, vertical bar, tilde, quote, question mark, colon, and semicolon.)


Next: , Previous: , Up: Top   [Contents][Index]

2 Data Structure Primitives


Next: , Previous: , Up: DATA STRUCTURE PRIMITIVES   [Contents][Index]

2.1 Constructors


Next: , Previous: , Up: CONSTRUCTORS   [Contents][Index]

word

WORD word1 word2
(WORD word1 word2 word3 ...)

outputs a word formed by concatenating its inputs.


Next: , Previous: , Up: CONSTRUCTORS   [Contents][Index]

list

LIST thing1 thing2
(LIST thing1 thing2 thing3 ...)

outputs a list whose members are its inputs, which can be any Logo datum (word, list, or array).


Next: , Previous: , Up: CONSTRUCTORS   [Contents][Index]

sentence

SENTENCE thing1 thing2
SE thing1 thing2
(SENTENCE thing1 thing2 thing3 ...)
(SE thing1 thing2 thing3 ...)

outputs a list whose members are its inputs, if those inputs are not lists, or the members of its inputs, if those inputs are lists.


Next: , Previous: , Up: CONSTRUCTORS   [Contents][Index]

fput

FPUT thing list

outputs a list equal to its second input with one extra member, the first input, at the beginning. If the second input is a word, then the first input must be a one-letter word, and FPUT is equivalent to WORD.


Next: , Previous: , Up: CONSTRUCTORS   [Contents][Index]

lput

LPUT thing list

outputs a list equal to its second input with one extra member, the first input, at the end. If the second input is a word, then the first input must be a one-letter word, and LPUT is equivalent to WORD with its inputs in the other order.


Next: , Previous: , Up: CONSTRUCTORS   [Contents][Index]

array

ARRAY size
(ARRAY size origin)

outputs an array of size members (must be a positive integer), each of which initially is an empty list. Array members can be selected with ITEM and changed with SETITEM. The first member of the array is member number 1 unless an origin input (must be an integer) is given, in which case the first member of the array has that number as its index. (Typically 0 is used as the origin if anything.) Arrays are printed by PRINT and friends, and can be typed in, inside curly braces; indicate an origin with {a b c}@0.

See ITEM , SETITEM .


Next: , Previous: , Up: CONSTRUCTORS   [Contents][Index]

mdarray

MDARRAY sizelist				(library procedure)
(MDARRAY sizelist origin)

outputs a multi-dimensional array. The first input must be a list of one or more positive integers. The second input, if present, must be a single integer that applies to every dimension of the array.

Ex: (MDARRAY [3 5] 0) outputs a two-dimensional array whose members range from [0 0] to [2 4].


Next: , Previous: , Up: CONSTRUCTORS   [Contents][Index]

listtoarray

LISTTOARRAY list
(LISTTOARRAY list origin)

outputs an array of the same size as the input list, whose members are the members of the input list.


Next: , Previous: , Up: CONSTRUCTORS   [Contents][Index]

arraytolist

ARRAYTOLIST array

outputs a list whose members are the members of the input array. The first member of the output is the first member of the array, regardless of the array’s origin.


Next: , Previous: , Up: CONSTRUCTORS   [Contents][Index]

combine

COMBINE thing1 thing2				(library procedure)

if thing2 is a word, outputs WORD thing1 thing2. If thing2 is a list, outputs FPUT thing1 thing2.

See WORD , FPUT


Next: , Previous: , Up: CONSTRUCTORS   [Contents][Index]

reverse

REVERSE list					(library procedure)

outputs a list whose members are the members of the input list, in reverse order.


Previous: , Up: CONSTRUCTORS   [Contents][Index]

gensym

GENSYM						(library procedure)

outputs a unique word each time it’s invoked. The words are of the form G1, G2, etc.


Next: , Previous: , Up: DATA STRUCTURE PRIMITIVES   [Contents][Index]

2.2 Data Selectors


Next: , Previous: , Up: SELECTORS   [Contents][Index]

first

FIRST thing

if the input is a word, outputs the first character of the word. If the input is a list, outputs the first member of the list. If the input is an array, outputs the origin of the array (that is, the index of the first member of the array).


Next: , Previous: , Up: SELECTORS   [Contents][Index]

firsts

FIRSTS list

outputs a list containing the FIRST of each member of the input list. It is an error if any member of the input list is empty. (The input itself may be empty, in which case the output is also empty.) This could be written as

to firsts :list
output map "first :list
end

but is provided as a primitive in order to speed up the iteration tools MAP, MAP.SE, and FOREACH.

to transpose :matrix
if emptyp first :matrix [op []]
op fput firsts :matrix transpose bfs :matrix
end

Next: , Previous: , Up: SELECTORS   [Contents][Index]

last

LAST wordorlist

if the input is a word, outputs the last character of the word. If the input is a list, outputs the last member of the list.


Next: , Previous: , Up: SELECTORS   [Contents][Index]

butfirst

BUTFIRST wordorlist
BF wordorlist

if the input is a word, outputs a word containing all but the first character of the input. If the input is a list, outputs a list containing all but the first member of the input.


Next: , Previous: , Up: SELECTORS   [Contents][Index]

butfirsts

BUTFIRSTS list
BFS list

outputs a list containing the BUTFIRST of each member of the input list. It is an error if any member of the input list is empty or an array. (The input itself may be empty, in which case the output is also empty.) This could be written as

to butfirsts :list
output map "butfirst :list
end

but is provided as a primitive in order to speed up the iteration tools MAP, MAP.SE, and FOREACH.


Next: , Previous: , Up: SELECTORS   [Contents][Index]

butlast

BUTLAST wordorlist
BL wordorlist

if the input is a word, outputs a word containing all but the last character of the input. If the input is a list, outputs a list containing all but the last member of the input.


Next: , Previous: , Up: SELECTORS   [Contents][Index]

item

ITEM index thing

if the thing is a word, outputs the indexth character of the word. If the thing is a list, outputs the indexth member of the list. If the thing is an array, outputs the indexth member of the array. Index starts at 1 for words and lists; the starting index of an array is specified when the array is created.


Next: , Previous: , Up: SELECTORS   [Contents][Index]

mditem

MDITEM indexlist array				(library procedure)

outputs the member of the multidimensional array selected by the list of numbers indexlist.


Next: , Previous: , Up: SELECTORS   [Contents][Index]

pick

PICK list					(library procedure)

outputs a randomly chosen member of the input list.


Next: , Previous: , Up: SELECTORS   [Contents][Index]

remove

REMOVE thing list				(library procedure)

outputs a copy of list with every member equal to thing removed.


Next: , Previous: , Up: SELECTORS   [Contents][Index]

remdup

REMDUP list					(library procedure)

outputs a copy of list with duplicate members removed. If two or more members of the input are equal, the rightmost of those members is the one that remains in the output.


Previous: , Up: SELECTORS   [Contents][Index]

quoted

QUOTED thing					(library procedure)

outputs its input, if a list; outputs its input with a quotation mark prepended, if a word.


Next: , Previous: , Up: DATA STRUCTURE PRIMITIVES   [Contents][Index]

2.3 Data Mutators


Next: , Previous: , Up: MUTATORS   [Contents][Index]

setitem

SETITEM index array value

command. Replaces the indexth member of array with the new value. Ensures that the resulting array is not circular, i.e., value may not be a list or array that contains array.


Next: , Previous: , Up: MUTATORS   [Contents][Index]

mdsetitem

MDSETITEM indexlist array value			(library procedure)

command. Replaces the member of array chosen by indexlist with the new value.


Next: , Previous: , Up: MUTATORS   [Contents][Index]

.setfirst

.SETFIRST list value

command. Changes the first member of list to be value.

WARNING: Primitives whose names start with a period are dangerous. Their use by non-experts is not recommended. The use of .SETFIRST can lead to circular list structures, which will get some Logo primitives into infinite loops, and to unexpected changes to other data structures that share storage with the list being modified.


Next: , Previous: , Up: MUTATORS   [Contents][Index]

.setbf

.SETBF list value

command. Changes the butfirst of list to be value.

WARNING: Primitives whose names start with a period are dangerous. Their use by non-experts is not recommended. The use of .SETBF can lead to circular list structures, which will get some Logo primitives into infinite loops; unexpected changes to other data structures that share storage with the list being modified; or to Logo crashes and coredumps if the butfirst of a list is not itself a list.


Next: , Previous: , Up: MUTATORS   [Contents][Index]

.setitem

.SETITEM index array value

command. Changes the indexth member of array to be value, like SETITEM, but without checking for circularity.

WARNING: Primitives whose names start with a period are dangerous. Their use by non-experts is not recommended. The use of .SETITEM can lead to circular arrays, which will get some Logo primitives into infinite loops.

See SETITEM.


Next: , Previous: , Up: MUTATORS   [Contents][Index]

push

PUSH stackname thing				(library procedure)

command. Adds the thing to the stack that is the value of the variable whose name is stackname. This variable must have a list as its value; the initial value should be the empty list. New members are added at the front of the list.


Next: , Previous: , Up: MUTATORS   [Contents][Index]

pop

POP stackname					(library procedure)

outputs the most recently PUSHed member of the stack that is the value of the variable whose name is stackname and removes that member from the stack.


Next: , Previous: , Up: MUTATORS   [Contents][Index]

queue

QUEUE queuename thing				(library procedure)

command. Adds the thing to the queue that is the value of the variable whose name is queuename. This variable must have a list as its value; the initial value should be the empty list. New members are added at the back of the list.


Previous: , Up: MUTATORS   [Contents][Index]

dequeue

DEQUEUE queuename				(library procedure)

outputs the least recently QUEUEd member of the queue that is the value of the variable whose name is queuename and removes that member from the queue.


Next: , Previous: , Up: DATA STRUCTURE PRIMITIVES   [Contents][Index]

2.4 Predicates


Next: , Previous: , Up: PREDICATES   [Contents][Index]

wordp

WORDP thing
WORD? thing

outputs TRUE if the input is a word, FALSE otherwise.


Next: , Previous: , Up: PREDICATES   [Contents][Index]

listp

LISTP thing
LIST? thing

outputs TRUE if the input is a list, FALSE otherwise.


Next: , Previous: , Up: PREDICATES   [Contents][Index]

arrayp

ARRAYP thing
ARRAY? thing

outputs TRUE if the input is an array, FALSE otherwise.


Next: , Previous: , Up: PREDICATES   [Contents][Index]

emptyp

EMPTYP thing
EMPTY? thing

outputs TRUE if the input is the empty word or the empty list, FALSE otherwise.


Next: , Previous: , Up: PREDICATES   [Contents][Index]

equalp

EQUALP thing1 thing2
EQUAL? thing1 thing2
thing1 = thing2

outputs TRUE if the inputs are equal, FALSE otherwise. Two numbers are equal if they have the same numeric value. Two non-numeric words are equal if they contain the same characters in the same order. If there is a variable named CASEIGNOREDP whose value is TRUE, then an upper case letter is considered the same as the corresponding lower case letter. (This is the case by default.) Two lists are equal if their members are equal. An array is only equal to itself; two separately created arrays are never equal even if their members are equal. (It is important to be able to know if two expressions have the same array as their value because arrays are mutable; if, for example, two variables have the same array as their values then performing SETITEM on one of them will also change the other.)

See CASEIGNOREDP , SETITEM


Next: , Previous: , Up: PREDICATES   [Contents][Index]

notequalp

NOTEQUALP thing1 thing2
NOTEQUAL? thing1 thing2
thing1 <> thing2

outputs FALSE if the inputs are equal, TRUE otherwise. See EQUALP for the meaning of equality for different data types.


Next: , Previous: , Up: PREDICATES   [Contents][Index]

beforep

BEFOREP word1 word2
BEFORE? word1 word2

outputs TRUE if word1 comes before word2 in ASCII collating sequence (for words of letters, in alphabetical order). Case-sensitivity is determined by the value of CASEIGNOREDP. Note that if the inputs are numbers, the result may not be the same as with LESSP; for example, BEFOREP 3 12 is false because 3 collates after 1.

See CASEIGNOREDP , LESSP


Next: , Previous: , Up: PREDICATES   [Contents][Index]

.eq

.EQ thing1 thing2

outputs TRUE if its two inputs are the same datum, so that applying a mutator to one will change the other as well. Outputs FALSE otherwise, even if the inputs are equal in value.

WARNING: Primitives whose names start with a period are dangerous. Their use by non-experts is not recommended. The use of mutators can lead to circular data structures, infinite loops, or Logo crashes.


Next: , Previous: , Up: PREDICATES   [Contents][Index]

memberp

MEMBERP thing1 thing2
MEMBER? thing1 thing2

if thing2 is a list or an array, outputs TRUE if thing1 is EQUALP to a member of thing2, FALSE otherwise. If thing2 is a word, outputs TRUE if thing1 is a one-character word EQUALP to a character of thing2, FALSE otherwise.

See EQUALP .


Next: , Previous: , Up: PREDICATES   [Contents][Index]

substringp

SUBSTRINGP thing1 thing2
SUBSTRING? thing1 thing2

if thing1 or thing2 is a list or an array, outputs FALSE. If thing2 is a word, outputs TRUE if thing1 is EQUALP to a substring of thing2, FALSE otherwise.

See EQUALP .


Next: , Previous: , Up: PREDICATES   [Contents][Index]

numberp

NUMBERP thing
NUMBER? thing

outputs TRUE if the input is a number, FALSE otherwise.


Previous: , Up: PREDICATES   [Contents][Index]

vbarredp

VBARREDP char
VBARRED? char
BACKSLASHEDP char                               (library procedure)
BACKSLASHED? char                               (library procedure)

outputs TRUE if the input character was originally entered into Logo within vertical bars (|) to prevent its usual special syntactic meaning, FALSE otherwise. (Outputs TRUE only if the character is a backslashed space, tab, newline, or one of ()[]+-*/=<>":;\~?| )

The names BACKSLASHEDP and BACKSLASHED? are included in the Logo library for backward compatibility with the former names of this primitive, although it does not output TRUE for characters originally entered with backslashes.


Previous: , Up: DATA STRUCTURE PRIMITIVES   [Contents][Index]

2.5 Queries


Next: , Previous: , Up: QUERIES   [Contents][Index]

count

COUNT thing

outputs the number of characters in the input, if the input is a word; outputs the number of members in the input, if it is a list or an array. (For an array, this may or may not be the index of the last member, depending on the array’s origin.)


Next: , Previous: , Up: QUERIES   [Contents][Index]

ascii

ASCII char

outputs the integer (between 0 and 255) that represents the input character in the ASCII code. Interprets control characters as representing vbarred punctuation, and returns the character code for the corresponding punctuation character without vertical bars. (Compare RAWASCII.)


Next: , Previous: , Up: QUERIES   [Contents][Index]

rawascii

RAWASCII char

outputs the integer (between 0 and 255) that represents the input character in the ASCII code. Interprets control characters as representing themselves. To find out the ASCII code of an arbitrary keystroke, use RAWASCII RC.


Next: , Previous: , Up: QUERIES   [Contents][Index]

char

CHAR int

outputs the character represented in the ASCII code by the input, which must be an integer between 0 and 255.

See ASCII .


Next: , Previous: , Up: QUERIES   [Contents][Index]

member

MEMBER thing1 thing2

if thing2 is a word or list and if MEMBERP with these inputs would output TRUE, outputs the portion of thing2 from the first instance of thing1 to the end. If MEMBERP would output FALSE, outputs the empty word or list according to the type of thing2. It is an error for thing2 to be an array.

See MEMBERP .


Next: , Previous: , Up: QUERIES   [Contents][Index]

lowercase

LOWERCASE word

outputs a copy of the input word, but with all uppercase letters changed to the corresponding lowercase letter.


Next: , Previous: , Up: QUERIES   [Contents][Index]

uppercase

UPPERCASE word

outputs a copy of the input word, but with all lowercase letters changed to the corresponding uppercase letter.


Next: , Previous: , Up: QUERIES   [Contents][Index]

standout

STANDOUT thing

outputs a word that, when printed, will appear like the input but displayed in standout mode (boldface, reverse video, or whatever your version does for standout). The word contains machine-specific magic characters at the beginning and end; in between is the printed form (as if displayed using TYPE) of the input. The output is always a word, even if the input is of some other type, but it may include spaces and other formatting characters. Note: a word output by STANDOUT while Logo is running on one machine will probably not have the desired effect if printed on another type of machine.

In the Macintosh classic version, the way that standout works is incompatible with the use of characters whose ASCII code is greater than 127. Therefore, you have a choice to make: The instruction

CANINVERSE 0 

disables standout, but enables the display of ASCII codes above 127, and the instruction

CANINVERSE 1 

restores the default situation in which standout is enabled and the extra graphic characters cannot be printed.


Next: , Previous: , Up: QUERIES   [Contents][Index]

parse

PARSE word

outputs the list that would result if the input word were entered in response to a READLIST operation. That is, PARSE READWORD has the same value as READLIST for the same characters read.

See READLIST .


Previous: , Up: QUERIES   [Contents][Index]

runparse

RUNPARSE wordorlist

outputs the list that would result if the input word or list were entered as an instruction line; characters such as infix operators and parentheses are separate members of the output. Note that sublists of a runparsed list are not themselves runparsed.


Next: , Previous: , Up: Top   [Contents][Index]

3 Objects

Note: The object implementation in UCBLogo is new and still being worked on. It also is optional and may not be compiled into the version you are using. Bug reports and patches are greatly appreciated.

An object is a data structure, like a list, except that instead of just a sequence of elements, an object has named elements, which are either variables or procedures. (A procedure that belongs to an object is sometimes called a method.) In the object metaphor, instead of just having the one computer that does everything, we think of each object as capable of doing things. One object can ask another object to do something for it.

At any moment, there is a current object. That object might have its own version of procedures that are available globally and documented in this manual. So workspace operations such as pots or erase might have different effects depending on the current object.

The initial current object is called logo; there is an operation that outputs that object. Every object has one or more parents, and ultimately the parent of the parent... of an object has to be logo. The primitive procedures in this manual belong to the logo object, as do global variables.

Turtles are objects. This is valuable in part so that you can customize the behavior of a turtle. For example, if you’re simulating a kaleidoscope, you might want half your turtles to swap the meanings of the left and right commands. But given what’s said above about there being a current object, and that the initial current object is logo, which isn’t a turtle, you might think that you can’t run forward 100 without first creating a turtle object and making it the current object. But a goal of this object system is that things that were easy in traditional Logo should still be easy. And so, in addition to the current object, there is also a default turtle; if a turtle procedure is addressed to an object that isn’t a turtle, there is a logo procedure for each turtle procedure that does the equivalent of

to forward :distance
ask defaultturtle [forward :distance]
end

Unlike some other object oriented languages, Berkeley Logo does not distinguish between classes (kinds of objects, which mostly specify the procedures (the methods) of objects of that kind) and instances (individual concrete objects, with state memory in the form of variables belonging to the instance). Instead we use prototyping OOP, in which any object (instance) can serve as the model, the prototype (the class), for other objects.

Class/instance OOP is the right thing for large teams of programmers who need a detailed specification (in the form of class definitions) of the desired program behavior before they start writing code. But prototyping OOP is the right thing for tinkering, for having a glimmer of an idea and playing around with it without a rigid specification. So, you want to have dogs in your program. You start by building a dog, one you can see on the screen as you invent behaviors such as roll.over and wag.tail. Then you make a bunch of objects with that dog as their parent, using that dog as a prototype. But the prototype dog is still a particular dog, with a particular position, color, and so on.

Having said that, sometimes you do want to distinguish a class object, which will mostly have procedures, with few or no variables, and its instance objects, which mostly inherit procedures from the class, but have their own individual variables. To accommodate that style of work, we distinguish two ways to make a child object from a parent object. Kindof takes an object as input, and outputs a new object that inherits from the input object. This is how to make a subclass that is mostly like the given class, but overrides certain behaviors. Oneof makes a child object, but asks the new object to exist before outputting it. Every object has an exist procedure, because it inherits one from logo if no intermediate ancestor specifies one. The details come a little later in this section, in the Constructors subsection, but this is the general idea of how class/instance programming can be accommodated in a prototyping OOP language.


Next: , Previous: , Up: OBJECTS   [Contents][Index]

3.1 Constructors


Next: , Previous: , Up: OBJECT CONSTRUCTORS   [Contents][Index]

kindof

KINDOF object
KINDOF objectlist
(KINDOF object1 object2 ...)

creates and outputs an object whose parent is object, or whose parents are object1, object2, etc., or the elements of objectlist. There must be at least one input, and if a list, it may not be empty.


Next: , Previous: , Up: OBJECT CONSTRUCTORS   [Contents][Index]

something

SOMETHING

creates and outputs an object whose parent is the Logo object. make "foo something is equivalent to make "foo kindof logo.


Previous: , Up: OBJECT CONSTRUCTORS   [Contents][Index]

oneof

ONEOF object
ONEOF objectlist
(ONEOF object input1 input2 ...)
(ONEOF objectlist input1 input2 ...)

creates an object whose parent is object or whose parents are the elements of objectlist. Asks the new object to exist, and then outputs the object. Before the object is Asked to exist, all remaining inputs after the first are collected into a list, which is made the value of the global variable initlist. The convention is that initlist contains alternating names and values, which serve to initialize the newly created object.

The output of oneof is usually called an instance.

See EXIST.


Next: , Previous: , Up: OBJECTS   [Contents][Index]

3.2 Mutators


Next: , Previous: , Up: OBJECT MUTATORS   [Contents][Index]

exist

exist

Initializes a new object. It is run automatically by oneof.

The default exist procedure creates object-local variables with the odd-numbered elements of initlist as names, and the corresponding even-numbered elements as values. Thus

make "obj (oneof logo "foo "bar "baz "garply)

will create a new object and then tell it to exist, which will in effect tell it to

havemake "foo "bar
havemake "baz "garply

Example: Objects do not usually keep track of their instances. To make one that does, you can specialize exist:

? make "recordingobject something
? ask :recordingobject [havemake "instances []]
? ask :recordingobject [to exist]
> usual.exist
> make "instances [fput self :instances]
> end

See ONEOF. USUAL, HAVEMAKE.


Next: , Previous: , Up: OBJECT MUTATORS   [Contents][Index]

have

HAVE name
HAVE namelist

tells the current object to create an object variable named name, or object variables whose names are the elements of namelist.

See HAVEMAKE.


Previous: , Up: OBJECT MUTATORS   [Contents][Index]

havemake

HAVEMAKE name value

tells the current object to create an object variable named name, and give it the value value. Since procedure input values are computed before the procedure is run, the value expression may refer to the object’s parent’s variable named name:

havemake "size :size/2

See HAVE, MAKE.


Next: , Previous: , Up: OBJECTS   [Contents][Index]

3.3 selectors

All selectors apply to the current object. If you want to select from another object, use ask.


Next: , Previous: , Up: OBJECT SELECTORS   [Contents][Index]

self

SELF

outputs the current object (not its name!).


Next: , Previous: , Up: OBJECT SELECTORS   [Contents][Index]

parents

PARENTS

outputs a list containing the parent(s) of the current object. All objects except for logo have at least one parent. Note that the elements of the output list are objects, not names of objects.

Examples:

to grandparents
output remdup (map.se [ask ? [parents]] parents)
end

to ancestors
if emptyp parents [output (list self)]   ; can happen only if self=logo
output remdup sentence parents map.se [ask ? [ancestors]] parents
end

Next: , Previous: , Up: OBJECT SELECTORS   [Contents][Index]

mynames

MYNAMES

output a list of the names of the object variables owned (not inherited) by the current object.


Next: , Previous: , Up: OBJECT SELECTORS   [Contents][Index]

mynamep

MYNAMEP name
MYNAME? name

outputs true if name is the name of an object variable owned (not inherited) by the current object, false otherwise.

See MYNAMES.


Next: , Previous: , Up: OBJECT SELECTORS   [Contents][Index]

myprocs

MYPROCS

outputs a list of the names of the procedures (methods) owned by (not inherited by) the current object.


Previous: , Up: OBJECT SELECTORS   [Contents][Index]

myprocp

MYPROCP name
MYPROC? name

outputs true if name is the name of a procedure (a method) owned (not inherited) by the current object, false otherwise.

See MYPROCS.


Next: , Previous: , Up: OBJECTS   [Contents][Index]

3.4 Messages

The procedures in this section are for changing the current object, either permanently (unless changed again) or just to send one message.


Next: , Up: MESSAGES   [Contents][Index]

talkto

TALKTO object

changes the current object to object. (Note that the input is an object, not the name of an object.) Talkto can be used only at toplevel or within a pause (when typing into a Logo prompt, not inside a procedure).

See ASK.


Previous: , Up: MESSAGES   [Contents][Index]

ask

ASK object runlist

command or operation. Temporarily sets the current object to object while running the instructions or expression in runlist. If runlist is an expression, then ask outputs its value. As soon as runlist finishes, the current object is set back to its previous value.

See TALKTO.


Next: , Previous: , Up: OBJECTS   [Contents][Index]

3.5 Queries

These procedures are particularly useful when debugging.


Next: , Previous: , Up: OBJECT QUERIES   [Contents][Index]

whosename

WHOSENAME name

outputs the object that owns the currently accessible variable named name. If there is no such accessible variable, or it’s a procedure-local variable, an error is signalled.


Previous: , Up: OBJECT QUERIES   [Contents][Index]

whoseproc

WHOSEPROC name

outputs the object that owns the currently accessible procedure named name. If there is no such procedure, an error is signalled.


Previous: , Up: OBJECTS   [Contents][Index]

3.6 usual

to foo ...
...
USUAL.foo ...
...
end

Usual is not a procedure. It’s a special notation that can be used only inside a procedure definition; the word usual must be followed by a period and then the name of the procedure being defined. (That is, usual.foo can be used only inside the definition of foo.) It refers to the procedure that would be inherited from a parent if this (re)definition didn’t exist; it allows a specialized method to invoke the ordinary version.

make "bigturtle kindof turtle
ask :bigturtle [to forward :length]
usual.forward 2 * :length
end

If there is no inherited procedure of the same name, then calling usual.___ does nothing if used as a command, or outputs an empty list if used as an operation.

If an object has multiple parents, the behavior of usual may be confusing. Suppose the current object has two parents, A and B, in that order. Then usual.foo in the current object’s own foo method refers to object A’s foo, but usual.foo within object A’s foo refers to object B’s foo in this situation, even though A’s parent isn’t B.

make "dashedturtle kindof turtle
ask :dashedturtle [to forward :length]
if not pendownp [usual.forward :length stop]
if :length <= 5 [usual.forward :length stop]
usual.forward 5
penup
usual.forward (ifelse :length <= 10 [:length-5] [5])
pendown
if :length > 10 [forward :length-10]    ; Note no USUAL here.
end

ask :dashedturtle [forward 25]
- - -â–º

make "bigdashed oneof (list :bigturtle :dashedturtle)
make "dashedbig oneof (list :dashedturtle :bigturtle)
ask :bigdashed [forward 25]
- - - - - â–º
ask :dashedbig [forward 25]
--  --  --â–º

Next: , Previous: , Up: Top   [Contents][Index]

4 Communication


Next: , Previous: , Up: COMMUNICATION   [Contents][Index]

4.1 Transmitters

Note: If there is a variable named PRINTDEPTHLIMIT with a nonnegative integer value, then complex list and array structures will be printed only to the allowed depth. That is, members of members of... of members will be allowed only so far. The members omitted because they are just past the depth limit are indicated by an ellipsis for each one, so a too-deep list of two members will print as [... ...].

If there is a variable named PRINTWIDTHLIMIT with a nonnegative integer value, then only the first so many members of any array or list will be printed. A single ellipsis replaces all missing data within the structure. The width limit also applies to the number of characters printed in a word, except that a PRINTWIDTHLIMIT between 0 and 9 will be treated as if it were 10 when applied to words. This limit applies not only to the top-level printed datum but to any substructures within it.

See PRINTDEPTHLIMIT , PRINTWIDTHLIMIT

If there is a variable named FULLPRINTP whose value is TRUE, then words that were created using backslash or vertical bar (to include characters that would otherwise not be treated as part of a word) are printed with the backslashes or vertical bars shown, so that the printed result could be re-read by Logo to produce the same value. If FULLPRINTP is TRUE then the empty word (however it was created) prints as ||. (Otherwise it prints as nothing at all.)

See FULLPRINTP .


Next: , Previous: , Up: TRANSMITTERS   [Contents][Index]

print

PRINT thing
PR thing
(PRINT thing1 thing2 ...)
(PR thing1 thing2 ...)

command. Prints the input or inputs to the current write stream (initially the screen). All the inputs are printed on a single line, separated by spaces, ending with a newline. If an input is a list, square brackets are not printed around it, but brackets are printed around sublists. Braces are always printed around arrays.


Next: , Previous: , Up: TRANSMITTERS   [Contents][Index]

type

TYPE thing
(TYPE thing1 thing2 ...)

command. Prints the input or inputs like PRINT, except that no newline character is printed at the end and multiple inputs are not separated by spaces. Note: printing to the screen is ordinarily line buffered; that is, the characters you print using TYPE will not actually appear on the screen until either a newline character is printed (for example, by PRINT or SHOW) or Logo tries to read from the keyboard (either at the request of your program or after an instruction prompt). This buffering makes the program much faster than it would be if each character appeared immediately, and in most cases the effect is not disconcerting. To accommodate programs that do a lot of positioned text display using TYPE, Logo will force printing whenever SETCURSOR is invoked. This solves most buffering problems. Still, on occasion you may find it necessary to force the buffered characters to be printed explicitly; this can be done using the WAIT command. WAIT 0 will force printing without actually waiting.

See SETCURSOR , WAIT


Previous: , Up: TRANSMITTERS   [Contents][Index]

show

SHOW thing
(SHOW thing1 thing2 ...)

command. Prints the input or inputs like PRINT, except that if an input is a list it is printed inside square brackets.

See PRINT .


Next: , Previous: , Up: COMMUNICATION   [Contents][Index]

4.2 Receivers


Next: , Previous: , Up: RECEIVERS   [Contents][Index]

readlist

READLIST
RL

reads a line from the read stream (initially the keyboard) and outputs that line as a list. The line is separated into members as though it were typed in square brackets in an instruction. If the read stream is a file, and the end of file is reached, READLIST outputs the empty word (not the empty list). READLIST processes backslash, vertical bar, and tilde characters in the read stream; the output list will not contain these characters but they will have had their usual effect. READLIST does not, however, treat semicolon as a comment character.


Next: , Previous: , Up: RECEIVERS   [Contents][Index]

readword

READWORD
RW

reads a line from the read stream and outputs that line as a word. The output is a single word even if the line contains spaces, brackets, etc. If the read stream is a file, and the end of file is reached, READWORD outputs the empty list (not the empty word). READWORD processes backslash, vertical bar, and tilde characters in the read stream. In the case of a tilde used for line continuation, the output word does include the tilde and the newline characters, so that the user program can tell exactly what the user entered. Vertical bars in the line are also preserved in the output. Backslash characters are not preserved in the output.


Next: , Previous: , Up: RECEIVERS   [Contents][Index]

readrawline

READRAWLINE

reads a line from the read stream and outputs that line as a word. The output is a single word even if the line contains spaces, brackets, etc. If the read stream is a file, and the end of file is reached, READRAWLINE outputs the empty list (not the empty word). READRAWLINE outputs the exact string of characters as they appear in the line, with no special meaning for backslash, vertical bar, tilde, or any other formatting characters.

See READWORD .


Next: , Previous: , Up: RECEIVERS   [Contents][Index]

readchar

READCHAR
RC

reads a single character from the read stream and outputs that character as a word. If the read stream is a file, and the end of file is reached, READCHAR outputs the empty list (not the empty word). If the read stream is the keyboard, echoing is turned off when READCHAR is invoked, and remains off until READLIST or READWORD is invoked or a Logo prompt is printed. Backslash, vertical bar, and tilde characters have no special meaning in this context.

See READLIST .


Next: , Previous: , Up: RECEIVERS   [Contents][Index]

readchars

READCHARS num
RCS num

reads num characters from the read stream and outputs those characters as a word. If the read stream is a file, and the end of file is reached, READCHARS outputs the empty list (not the empty word). If the read stream is the keyboard, echoing is turned off when READCHARS is invoked, and remains off until READLIST or READWORD is invoked or a Logo prompt is printed. Backslash, vertical bar, and tilde characters have no special meaning in this context.

See READLIST , READWORD


Previous: , Up: RECEIVERS   [Contents][Index]

shell

SHELL command
(SHELL command wordflag)

Under Unix, outputs the result of running command as a shell command. (The command is sent to ‘/bin/sh’, not ‘csh’ or other alternatives.) If the command is a literal list in the instruction line, and if you want a backslash character sent to the shell, you must use \\ to get the backslash through Logo’s reader intact. The output is a list containing one member for each line generated by the shell command. Ordinarily each such line is represented by a list in the output, as though the line were read using READLIST. If a second input is given, regardless of the value of the input, each line is represented by a word in the output as though it were read with READWORD. Example:

to dayofweek
output first first shell [date]
end

This is first first to extract the first word of the first (and only) line of the shell output.

Under MacOS X, SHELL works as under Unix. SHELL is not available under Mac Classic.

Under DOS, SHELL is a command, not an operation; it sends its input to a DOS command processor but does not collect the result of the command.

Under Windows, the wxWidgets version of Logo behaves as under Unix (except that DOS-style commands are understood; use dir rather than ls). The non-wxWidgets version behaves like the DOS version.


Next: , Previous: , Up: COMMUNICATION   [Contents][Index]

4.3 File Access


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

setprefix

SETPREFIX string

command. Sets a prefix that will be used as the implicit beginning of filenames in OPENREAD, OPENWRITE, OPENAPPEND, OPENUPDATE, LOAD, and SAVE commands. Logo will put the appropriate separator character (slash for Unix, backslash for DOS/Windows, colon for MacOS Classic) between the prefix and the filename entered by the user. The input to SETPREFIX must be a word, unless it is the empty list, to indicate that there should be no prefix.

See OPENREAD , See OPENWRITE , See OPENAPPEND , See OPENUPDATE , See LOAD , See SAVE .


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

prefix

PREFIX

outputs the current file prefix, or [] if there is no prefix.

See SETPREFIX .


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

openread

OPENREAD filename

command. Opens the named file for reading. The read position is initially at the beginning of the file.


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

openwrite

OPENWRITE filename

command. Opens the named file for writing. If the file already existed, the old version is deleted and a new, empty file created.

OPENWRITE, but not the other OPEN variants, will accept as input a two-element list, in which the first element must be a variable name, and the second must be a positive integer. A character buffer of the specified size will be created. When a SETWRITE is done with this same list (in the sense of .EQ, not a copy, so you must do something like

? make "buf [foo 100]
? openwrite :buf
? setwrite :buf
    [...]
? close :buf

and not just

? openwrite [foo 100]
? setwrite [foo 100]

and so on), the printed characters are stored in the buffer; when a CLOSE is done with the same list as input, the characters from the buffer (treated as one long word, even if spaces and newlines are included) become the value of the specified variable.


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

openappend

OPENAPPEND filename

command. Opens the named file for writing. If the file already exists, the write position is initially set to the end of the old file, so that newly written data will be appended to it.


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

openupdate

OPENUPDATE filename

command. Opens the named file for reading and writing. The read and write position is initially set to the end of the old file, if any. Note: each open file has only one position, for both reading and writing. If a file opened for update is both READER and WRITER at the same time, then SETREADPOS will also affect WRITEPOS and vice versa. Also, if you alternate reading and writing the same file, you must SETREADPOS between a write and a read, and SETWRITEPOS between a read and a write.

See READER , WRITER , SETREADPOS , SETWRITEPOS


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

close

CLOSE filename

command. Closes the named file. If the file was currently the reader or writer, then the reader or writer is changed to the keyboard or screen, as if SETREAD [] or SETWRITE [] had been done.


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

allopen

ALLOPEN

outputs a list whose members are the names of all files currently open. This list does not include the dribble file, if any.


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

closeall

CLOSEALL					(library procedure)

command. Closes all open files. Abbreviates FOREACH ALLOPEN [CLOSE ?]

See FOREACH , CLOSE


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

erasefile

ERASEFILE filename
ERF filename

command. Erases (deletes, removes) the named file, which should not currently be open.


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

dribble

DRIBBLE filename

command. Creates a new file whose name is the input, like OPENWRITE, and begins recording in that file everything that is read from the keyboard or written to the terminal. That is, this writing is in addition to the writing to WRITER. The intent is to create a transcript of a Logo session, including things like prompt characters and interactions.

See OPENWRITE , WRITER


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

nodribble

NODRIBBLE

command. Stops copying information into the dribble file, and closes the file.


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

setread

SETREAD filename

command. Makes the named file the read stream, used for READLIST, etc. The file must already be open with OPENREAD or OPENUPDATE. If the input is the empty list, then the read stream becomes the keyboard, as usual. Changing the read stream does not close the file that was previously the read stream, so it is possible to alternate between files.

See READLIST , OPENREAD , OPENUPDATE


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

setwrite

SETWRITE filename

command. Makes the named file the write stream, used for PRINT, etc. The file must already be open with OPENWRITE, OPENAPPEND, or OPENUPDATE. If the input is the empty list, then the write stream becomes the screen, as usual. Changing the write stream does not close the file that was previously the write stream, so it is possible to alternate between files.

If the input is a list, then its first element must be a variable name, and its second and last element must be a positive integer; a buffer of that many characters will be allocated, and will become the writestream. If the same list (same in the .EQ sense, not a copy) has been used as input to OPENWRITE, then the already-allocated buffer will be used, and the writer can be changed to and from this buffer, with all the characters accumulated as in a file. When the same list is used as input to CLOSE, the contents of the buffer (as an unparsed word, which may contain newline characters) will become the value of the named variable. For compatibility with earlier versions, if the list has not been opened when the SETWRITE is done, it will be opened implicitly, but the first SETWRITE after this one will implicitly close it, setting the variable and freeing the allocated buffer.

See PRINT , OPENWRITE ; OPENAPPEND ; OPENUPDATE


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

reader

READER

outputs the name of the current read stream file, or the empty list if the read stream is the terminal.


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

writer

WRITER

outputs the name of the current write stream file, or the empty list if the write stream is the screen.


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

setreadpos

SETREADPOS charpos

command. Sets the file pointer of the read stream file so that the next READLIST, etc., will begin reading at the charposth character in the file, counting from 0. (That is, SETREADPOS 0 will start reading from the beginning of the file.) Meaningless if the read stream is the keyboard.

See READLIST .


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

setwritepos

SETWRITEPOS charpos

command. Sets the file pointer of the write stream file so that the next PRINT, etc., will begin writing at the charposth character in the file, counting from 0. (That is, SETWRITEPOS 0 will start writing from the beginning of the file.) Meaningless if the write stream is the screen.

See PRINT .


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

readpos

READPOS

outputs the file position of the current read stream file.


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

writepos

WRITEPOS

outputs the file position of the current write stream file.


Next: , Previous: , Up: FILE ACCESS   [Contents][Index]

eofp

EOFP
EOF?

predicate, outputs TRUE if there are no more characters to be read in the read stream file, FALSE otherwise.


Previous: , Up: FILE ACCESS   [Contents][Index]

filep

FILEP filename
FILE? filename					(library procedure)

predicate, outputs TRUE if a file of the specified name exists and can be read, FALSE otherwise.


Previous: , Up: COMMUNICATION   [Contents][Index]

4.4 Terminal Access


Next: , Previous: , Up: TERMINAL ACCESS   [Contents][Index]

keyp

KEYP
KEY?

predicate, outputs TRUE if there are characters waiting to be read from the read stream. If the read stream is a file, this is equivalent to NOT EOFP. If the read stream is the terminal, then echoing is turned off and the terminal is set to cbreak (character at a time instead of line at a time) mode. It remains in this mode until some line-mode reading is requested (e.g., READLIST). The Unix operating system forgets about any pending characters when it switches modes, so the first KEYP invocation will always output FALSE.

See EOFP , READLIST


Next: , Previous: , Up: TERMINAL ACCESS   [Contents][Index]

linep

LINEP
LINE?

predicate, outputs TRUE if there is a line waiting to be read from the read stream. If the read stream is a file, this is equivalent to NOT EOFP. If the read stream is the terminal, then typed characters will be displayed and may be edited until RET is pressed.

See EOFP .


Next: , Previous: , Up: TERMINAL ACCESS   [Contents][Index]

cleartext

CLEARTEXT
CT

command. Clears the text window.


Next: , Previous: , Up: TERMINAL ACCESS   [Contents][Index]

setcursor

SETCURSOR vector

command. The input is a list of two numbers, the x and y coordinates of a text window position (origin in the upper left corner, positive direction is southeast). The text cursor is moved to the requested position. This command also forces the immediate printing of any buffered characters.


Next: , Previous: , Up: TERMINAL ACCESS   [Contents][Index]

cursor

CURSOR

outputs a list containing the current x and y coordinates of the text cursor. Logo may get confused about the current cursor position if, e.g., you type in a long line that wraps around or your program prints escape codes that affect the screen strangely.


Next: , Previous: , Up: TERMINAL ACCESS   [Contents][Index]

setmargins

SETMARGINS vector

command. The input must be a list of two numbers, as for SETCURSOR. The effect is to clear the screen and then arrange for all further printing to be shifted down and to the right according to the indicated margins. Specifically, every time a newline character is printed (explicitly or implicitly) Logo will type x_margin spaces, and on every invocation of SETCURSOR the margins will be added to the input x and y coordinates. (CURSOR will report the cursor position relative to the margins, so that this shift will be invisible to Logo programs.) The purpose of this command is to accommodate the display of terminal screens in lecture halls with inadequate TV monitors that miss the top and left edges of the screen.

See SETCURSOR .


Next: , Previous: , Up: TERMINAL ACCESS   [Contents][Index]

settextcolor

SETTEXTCOLOR foreground background
SETTC foreground background

command (wxWidgets only). The inputs are color numbers, or RGB color lists, as for turtle graphics. The foreground and background colors for the textscreen/splitscreen text window are changed to the given values. The change affects text already printed as well as future text printing; there is only one text color for the entire window.

Command (non-wxWidgets Windows and DOS extended only). The inputs are color numbers, as for turtle graphics. Future printing to the text window will use the specified colors for foreground (the characters printed) and background (the space under those characters). Using STANDOUT will revert to the default text window colors. In the DOS extended (ucblogo.exe) version, colors in textscreen mode are limited to numbers 0-7, and the coloring applies only to text printed by the program, not to the echoing of text typed by the user. Neither limitation applies to the text portion of splitscreen mode, which is actually drawn as graphics internally.

See STANDOUT .


Next: , Previous: , Up: TERMINAL ACCESS   [Contents][Index]

increasefont

INCREASEFONT
DECREASEFONT

command (wxWidgets only). Increase or decrease the size of the font used in the text and edit windows to the next larger or smaller available size.


Next: , Previous: , Up: TERMINAL ACCESS   [Contents][Index]

settextsize

SETTEXTSIZE height

command (wxWidgets only). Set the "point size" of the font used in the text and edit windows to the given integer input. The desired size may not be available, in which case the nearest available size will be used. Note: There is only a slight correlation between these integers and pixel sizes. Our rough estimate is that the number of pixels of height is about 1.5 times the point size, but it varies for different fonts. See SETLABELHEIGHT for a different approach used for the graphics window.


Next: , Previous: , Up: TERMINAL ACCESS   [Contents][Index]

textsize

TEXTSIZE

(wxWidgets only) outputs the "point size" of the font used in the text and edit windows. See SETTEXTSIZE for a discussion of font sizing. See LABELSIZE for a different approach used for the graphics window.


Next: , Previous: , Up: TERMINAL ACCESS   [Contents][Index]

setfont

SETFONT fontname

command (wxWidgets only). Set the font family used in all windows to the one named by the input. Try Courier or Monospace as likely possibilities. Not all computers have the same fonts installed. It’s a good idea to stick with monospace fonts (ones in which all characters have the same width).


Previous: , Up: TERMINAL ACCESS   [Contents][Index]

font

FONT

(wxWidgets only) outputs the name of the font family used in all windows.


Next: , Previous: , Up: Top   [Contents][Index]

5 Arithmetic


Next: , Previous: , Up: ARITHMETIC   [Contents][Index]

5.1 Numeric Operations


Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

sum

SUM num1 num2
(SUM num1 num2 num3 ...)
num1 + num2

outputs the sum of its inputs.


Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

difference

DIFFERENCE num1 num2
num1 - num2

outputs the difference of its inputs. Minus sign means infix difference in ambiguous contexts (when preceded by a complete expression), unless it is preceded by a space and followed by a nonspace. (See also MINUS.)


Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

minus

MINUS num
- num

outputs the negative of its input. Minus sign means unary minus if the previous token is an infix operator or open parenthesis, or it is preceded by a space and followed by a nonspace. There is a difference in binding strength between the two forms:

MINUS 3 + 4     means   -(3+4)
- 3 + 4         means   (-3)+4

Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

product

PRODUCT num1 num2
(PRODUCT num1 num2 num3 ...)
num1 * num2

outputs the product of its inputs.


Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

quotient

QUOTIENT num1 num2
(QUOTIENT num)
num1 / num2

outputs the quotient of its inputs. The quotient of two integers is an integer if and only if the dividend is a multiple of the divisor. (In other words, QUOTIENT 5 2 is 2.5, not 2, but QUOTIENT 4 2 is 2, not 2.0 — it does the right thing.) With a single input, QUOTIENT outputs the reciprocal of the input.


Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

remainder

REMAINDER num1 num2

outputs the remainder on dividing num1 by num2; both must be integers and the result is an integer with the same sign as num1.


Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

modulo

MODULO num1 num2

outputs the remainder on dividing num1 by num2; both must be integers and the result is an integer with the same sign as num2.


Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

int

INT num

outputs its input with fractional part removed, i.e., an integer with the same sign as the input, whose absolute value is the largest integer less than or equal to the absolute value of the input.


Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

round

ROUND num

outputs the nearest integer to the input.


Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

sqrt

SQRT num

outputs the square root of the input, which must be nonnegative.


Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

power

POWER num1 num2

outputs num1 to the num2 power. If num1 is negative, then num2 must be an integer.


Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

exp

EXP num

outputs e (2.718281828+) to the input power.


Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

log10

LOG10 num

outputs the common logarithm of the input.


Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

ln

LN num

outputs the natural logarithm of the input.


Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

sin

SIN degrees

outputs the sine of its input, which is taken in degrees.


Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

radsin

RADSIN radians

outputs the sine of its input, which is taken in radians.


Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

cos

COS degrees

outputs the cosine of its input, which is taken in degrees.


Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

radcos

RADCOS radians

outputs the cosine of its input, which is taken in radians.


Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

arctan

ARCTAN num
(ARCTAN x y)

outputs the arctangent, in degrees, of its input. With two inputs, outputs the arctangent of y/x, if x is nonzero, or 90 or –90 depending on the sign of y, if x is zero.


Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

radarctan

RADARCTAN num
(RADARCTAN x y)

outputs the arctangent, in radians, of its input. With two inputs, outputs the arctangent of y/x, if x is nonzero, or pi/2 or –pi/2 depending on the sign of y, if x is zero.

The expression 2*(RADARCTAN 0 1) can be used to get the value of pi.


Next: , Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

iseq

ISEQ from to					(library procedure)

outputs a list of the integers from from to to, inclusive.

? show iseq 3 7
[3 4 5 6 7]
? show iseq 7 3
[7 6 5 4 3]

Previous: , Up: NUMERIC OPERATIONS   [Contents][Index]

rseq

RSEQ from to count				(library procedure)

outputs a list of count equally spaced rational numbers between from and to, inclusive.

? show rseq 3 5 9 
[3 3.25 3.5 3.75 4 4.25 4.5 4.75 5] 
? show rseq 3 5 5
[3 3.5 4 4.5 5]

Next: , Previous: , Up: ARITHMETIC   [Contents][Index]

5.2 Numeric Predicates


Next: , Previous: , Up: NUMERIC PREDICATES   [Contents][Index]

lessp

LESSP num1 num2
LESS? num1 num2
num1 < num2

outputs TRUE if its first input is strictly less than its second.


Next: , Previous: , Up: NUMERIC PREDICATES   [Contents][Index]

greaterp

GREATERP num1 num2
GREATER? num1 num2
num1 > num2

outputs TRUE if its first input is strictly greater than its second.


Next: , Previous: , Up: NUMERIC PREDICATES   [Contents][Index]

lessequalp

LESSEQUALP num1 num2
LESSEQUAL? num1 num2
num1 <= num2

outputs TRUE if its first input is less than or equal to its second.


Previous: , Up: NUMERIC PREDICATES   [Contents][Index]

greaterequalp

GREATEREQUALP num1 num2
GREATEREQUAL? num1 num2
num1 >= num2

outputs TRUE if its first input is greater than or equal to its second.


Next: , Previous: , Up: ARITHMETIC   [Contents][Index]

5.3 Random Numbers


Next: , Previous: , Up: RANDOM NUMBERS   [Contents][Index]

random

RANDOM num
(RANDOM start end)

with one input, outputs a random nonnegative integer less than its input, which must be a positive integer.

With two inputs, RANDOM outputs a random integer greater than or equal to the first input, and less than or equal to the second input. Both inputs must be integers, and the first must be less than the second. (RANDOM 0 9) is equivalent to RANDOM 10; (RANDOM 3 8) is equivalent to (RANDOM 6)+3.


Previous: , Up: RANDOM NUMBERS   [Contents][Index]

rerandom

RERANDOM
(RERANDOM seed)

command. Makes the results of RANDOM reproducible. Ordinarily the sequence of random numbers is different each time Logo is used. If you need the same sequence of pseudo-random numbers repeatedly, e.g. to debug a program, say RERANDOM before the first invocation of RANDOM. If you need more than one repeatable sequence, you can give RERANDOM an integer input; each possible input selects a unique sequence of numbers.


Next: , Previous: , Up: ARITHMETIC   [Contents][Index]

5.4 Print Formatting


Previous: , Up: PRINT FORMATTING   [Contents][Index]

form

FORM num width precision

outputs a word containing a printable representation of num, possibly preceded by spaces (and therefore not a number for purposes of performing arithmetic operations), with at least width characters, including exactly precision digits after the decimal point. (If precision is 0 then there will be no decimal point in the output.)

As a debugging feature, (FORM num -1 format) will print the floating point num according to the C printf format, to allow

to hex :num
op form :num -1 "|%08X %08X|
end

to allow finding out the exact result of floating point operations. The precise format needed may be machine-dependent.


Previous: , Up: ARITHMETIC   [Contents][Index]

5.5 Bitwise Operations


Next: , Previous: , Up: BITWISE OPERATIONS   [Contents][Index]

bitand

BITAND num1 num2
(BITAND num1 num2 num3 ...)

outputs the bitwise and of its inputs, which must be integers.

See AND .


Next: , Previous: , Up: BITWISE OPERATIONS   [Contents][Index]

bitor

BITOR num1 num2
(BITOR num1 num2 num3 ...)

outputs the bitwise or of its inputs, which must be integers.

See OR .


Next: , Previous: , Up: BITWISE OPERATIONS   [Contents][Index]

bitxor

BITXOR num1 num2
(BITXOR num1 num2 num3 ...)

outputs the bitwise exclusive or of its inputs, which must be integers.


Next: , Previous: , Up: BITWISE OPERATIONS   [Contents][Index]

bitnot

BITNOT num

outputs the bitwise not of its input, which must be an integer.

See NOT .


Next: , Previous: , Up: BITWISE OPERATIONS   [Contents][Index]

ashift

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.


Previous: , Up: BITWISE OPERATIONS   [Contents][Index]

lshift

LSHIFT num1 num2

outputs num1 logical-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.


Next: , Previous: , Up: Top   [Contents][Index]

6 Logical Operations


Next: , Previous: , Up: LOGICAL OPERATIONS   [Contents][Index]

and

AND tf1 tf2
(AND tf1 tf2 tf3 ...)

outputs TRUE if all inputs are TRUE, otherwise FALSE. All inputs must be TRUE or FALSE. (Comparison is case-insensitive regardless of the value of CASEIGNOREDP. That is, true or True or TRUE are all the same.) An input can be a list, in which case it is taken as an expression to run; that expression must produce a TRUE or FALSE value. List expressions are evaluated from left to right; as soon as a FALSE value is found, the remaining inputs are not examined. Example:

MAKE "RESULT AND [NOT (:X = 0)] [(1 / :X) > .5]

to avoid the division by zero if the first part is false.


Next: , Previous: , Up: LOGICAL OPERATIONS   [Contents][Index]

or

OR tf1 tf2
(OR tf1 tf2 tf3 ...)

outputs TRUE if any input is TRUE, otherwise FALSE. All inputs must be TRUE or FALSE. (Comparison is case-insensitive regardless of the value of CASEIGNOREDP. That is, true or True or TRUE are all the same.) An input can be a list, in which case it is taken as an expression to run; that expression must produce a TRUE or FALSE value. List expressions are evaluated from left to right; as soon as a TRUE value is found, the remaining inputs are not examined. Example:

IF OR :X=0 [some.long.computation] [...]

to avoid the long computation if the first condition is met.


Previous: , Up: LOGICAL OPERATIONS   [Contents][Index]

not

NOT tf

outputs TRUE if the input is FALSE, and vice versa. The input can be a list, in which case it is taken as an expression to run; that expression must produce a TRUE or FALSE value.


Next: , Previous: , Up: Top   [Contents][Index]

7 Graphics

Berkeley Logo provides traditional Logo turtle graphics with one turtle. Multiple turtles, dynamic turtles, and collision detection are not supported. This is the most hardware-dependent part of Logo; some features may exist on some machines but not others. Nevertheless, the goal has been to make Logo programs as portable as possible, rather than to take fullest advantage of the capabilities of each machine. In particular, Logo attempts to scale the screen so that turtle coordinates [–100 –100] and [100 100] fit on the graphics window, and so that the aspect ratio is 1:1.

The center of the graphics window (which may or may not be the entire screen, depending on the machine used) is turtle location [0 0]. Positive X is to the right; positive Y is up. Headings (angles) are measured in degrees clockwise from the positive Y axis. (This differs from the common mathematical convention of measuring angles counterclockwise from the positive X axis.) The turtle is represented as an isoceles triangle; the actual turtle position is at the midpoint of the base (the short side). However, the turtle is drawn one step behind its actual position, so that the display of the base of the turtle’s triangle does not obscure a line drawn perpendicular to it (as would happen after drawing a square).

Colors are, of course, hardware-dependent. However, Logo provides partial hardware independence by interpreting color numbers 0 through 7 uniformly on all computers:

0  black        1  blue         2  green        3  cyan
4  red          5  magenta      6  yellow       7 white

Where possible, Logo provides additional user-settable colors; how many are available depends on the hardware and operating system environment. If at least 16 colors are available, Logo tries to provide uniform initial settings for the colors 8-15:

 8  brown        9  tan         10  forest      11  aqua
12  salmon      13  purple      14  orange      15  grey

Logo begins with a black background and white pen.


Next: , Previous: , Up: GRAPHICS   [Contents][Index]

7.1 Turtle Motion


Next: , Previous: , Up: TURTLE MOTION   [Contents][Index]

forward

FORWARD dist
FD dist

moves the turtle forward, in the direction that it’s facing, by the specified distance (measured in turtle steps).


Next: , Previous: , Up: TURTLE MOTION   [Contents][Index]

back

BACK dist
BK dist

moves the turtle backward, i.e., exactly opposite to the direction that it’s facing, by the specified distance. (The heading of the turtle does not change.)


Next: , Previous: , Up: TURTLE MOTION   [Contents][Index]

left

LEFT degrees
LT degrees

turns the turtle counterclockwise by the specified angle, measured in degrees (1/360 of a circle).


Next: , Previous: , Up: TURTLE MOTION   [Contents][Index]

right

RIGHT degrees
RT degrees

turns the turtle clockwise by the specified angle, measured in degrees (1/360 of a circle).


Next: , Previous: , Up: TURTLE MOTION   [Contents][Index]

setpos

SETPOS pos

moves the turtle to an absolute position in the graphics window. The input is a list of two numbers, the X and Y coordinates.


Next: , Previous: , Up: TURTLE MOTION   [Contents][Index]

setxy

SETXY xcor ycor

moves the turtle to an absolute position in the graphics window. The two inputs are numbers, the X and Y coordinates.


Next: , Previous: , Up: TURTLE MOTION   [Contents][Index]

setx

SETX xcor

moves the turtle horizontally from its old position to a new absolute horizontal coordinate. The input is the new X coordinate.


Next: , Previous: , Up: TURTLE MOTION   [Contents][Index]

sety

SETY ycor

moves the turtle vertically from its old position to a new absolute vertical coordinate. The input is the new Y coordinate.


Next: , Previous: , Up: TURTLE MOTION   [Contents][Index]

setheading

SETHEADING degrees
SETH degrees

turns the turtle to a new absolute heading. The input is a number, the heading in degrees clockwise from the positive Y axis.


Next: , Previous: , Up: TURTLE MOTION   [Contents][Index]

home

HOME

moves the turtle to the center of the screen. Equivalent to SETPOS [0 0] SETHEADING 0.

See SETPOS , See SETHEADING .


Previous: , Up: TURTLE MOTION   [Contents][Index]

arc

ARC angle radius

draws an arc of a circle, with the turtle at the center, with the specified radius, starting at the turtle’s heading and extending clockwise through the specified angle. The turtle does not move.


Next: , Previous: , Up: GRAPHICS   [Contents][Index]

7.2 Turtle Motion Queries


Next: , Previous: , Up: TURTLE MOTION QUERIES   [Contents][Index]

pos

POS

outputs the turtle’s current position, as a list of two numbers, the X and Y coordinates.


Next: , Previous: , Up: TURTLE MOTION QUERIES   [Contents][Index]

xcor

XCOR						(library procedure)

outputs a number, the turtle’s X coordinate.


Next: , Previous: , Up: TURTLE MOTION QUERIES   [Contents][Index]

ycor

YCOR						(library procedure)

outputs a number, the turtle’s Y coordinate.


Next: , Previous: , Up: TURTLE MOTION QUERIES   [Contents][Index]

heading

HEADING

outputs a number, the turtle’s heading in degrees.


Next: , Previous: , Up: TURTLE MOTION QUERIES   [Contents][Index]

towards

TOWARDS pos

outputs a number, the heading at which the turtle should be facing so that it would point from its current position to the position given as the input.


Previous: , Up: TURTLE MOTION QUERIES   [Contents][Index]

scrunch

SCRUNCH

outputs a list containing two numbers, the X and Y scrunch factors, as used by SETSCRUNCH. (But note that SETSCRUNCH takes two numbers as inputs, not one list of numbers.)

See SETSCRUNCH .


Next: , Previous: , Up: GRAPHICS   [Contents][Index]

7.3 Turtle and Window Control


Next: , Previous: , Up: TURTLE AND WINDOW CONTROL   [Contents][Index]

showturtle

SHOWTURTLE
ST

makes the turtle visible.


Next: , Previous: , Up: TURTLE AND WINDOW CONTROL   [Contents][Index]

hideturtle

HIDETURTLE
HT

makes the turtle invisible. It’s a good idea to do this while you’re in the middle of a complicated drawing, because hiding the turtle speeds up the drawing substantially.


Next: , Previous: , Up: TURTLE AND WINDOW CONTROL   [Contents][Index]

clean

CLEAN

erases all lines that the turtle has drawn on the graphics window. The turtle’s state (position, heading, pen mode, etc.) is not changed.


Next: , Previous: , Up: TURTLE AND WINDOW CONTROL   [Contents][Index]

clearscreen

CLEARSCREEN
CS

erases the graphics window and sends the turtle to its initial position and heading. Like HOME and CLEAN together.

See HOME .


Next: , Previous: , Up: TURTLE AND WINDOW CONTROL   [Contents][Index]

wrap

WRAP

tells the turtle to enter wrap mode: From now on, if the turtle is asked to move past the boundary of the graphics window, it will "wrap around" and reappear at the opposite edge of the window. The top edge wraps to the bottom edge, while the left edge wraps to the right edge. (So the window is topologically equivalent to a torus.) This is the turtle’s initial mode. Compare WINDOW and FENCE.

See FENCE .


Next: , Previous: , Up: TURTLE AND WINDOW CONTROL   [Contents][Index]

window

WINDOW

tells the turtle to enter window mode: From now on, if the turtle is asked to move past the boundary of the graphics window, it will move offscreen. The visible graphics window is considered as just part of an infinite graphics plane; the turtle can be anywhere on the plane. (If you lose the turtle, HOME will bring it back to the center of the window.) Compare WRAP and FENCE.


Next: , Previous: , Up: TURTLE AND WINDOW CONTROL   [Contents][Index]

fence

FENCE

tells the turtle to enter fence mode: From now on, if the turtle is asked to move past the boundary of the graphics window, it will move as far as it can and then stop at the edge with an "out of bounds" error message. Compare WRAP and WINDOW.

See WRAP .


Next: , Previous: , Up: TURTLE AND WINDOW CONTROL   [Contents][Index]

fill

FILL

fills in a region of the graphics window containing the turtle and bounded by lines that have been drawn earlier. This is not portable; it doesn’t work for all machines, and may not work exactly the same way on different machines.


Next: , Previous: , Up: TURTLE AND WINDOW CONTROL   [Contents][Index]

filled

FILLED color instructions

runs the instructions, remembering all points visited by turtle motion commands, starting and ending with the turtle’s initial position. Then draws (ignoring penmode) the resulting polygon, in the current pen color, filling the polygon with the given color, which can be a color number or an RGB list. The instruction list cannot include another FILLED invocation. (wxWidgets only)


Next: , Previous: , Up: TURTLE AND WINDOW CONTROL   [Contents][Index]

label

LABEL text

takes a word or list as input, and prints the input on the graphics window, starting at the turtle’s position.


Next: , Previous: , Up: TURTLE AND WINDOW CONTROL   [Contents][Index]

setlabelheight

SETLABELHEIGHT height

command (wxWidgets only). Takes a positive integer argument and tries to set the font size so that the character height (including descenders) is that many turtle steps. This will be different from the number of screen pixels if SETSCRUNCH has been used. Also, note that SETSCRUNCH changes the font size to try to preserve this height in turtle steps. Note that the query operation corresponding to this command is LABELSIZE, not LABELHEIGHT, because it tells you the width as well as the height of characters in the current font.


Next: , Previous: , Up: TURTLE AND WINDOW CONTROL   [Contents][Index]

textscreen

TEXTSCREEN
TS

rearranges the size and position of windows to maximize the space available in the text window (the window used for interaction with Logo). The details differ among machines. Compare SPLITSCREEN and FULLSCREEN.

See SPLITSCREEN .


Next: , Previous: , Up: TURTLE AND WINDOW CONTROL   [Contents][Index]

fullscreen

FULLSCREEN
FS

rearranges the size and position of windows to maximize the space available in the graphics window. The details differ among machines. Compare SPLITSCREEN and TEXTSCREEN.

Since there must be a text window to allow printing (including the printing of the Logo prompt), Logo automatically switches from fullscreen to splitscreen whenever anything is printed.

In the DOS version, switching from fullscreen to splitscreen loses the part of the picture that’s hidden by the text window. [This design decision follows from the scarcity of memory, so that the extra memory to remember an invisible part of a drawing seems too expensive.]


Next: , Previous: , Up: TURTLE AND WINDOW CONTROL   [Contents][Index]

splitscreen

SPLITSCREEN
SS

rearranges the size and position of windows to allow some room for text interaction while also keeping most of the graphics window visible. The details differ among machines. Compare TEXTSCREEN and FULLSCREEN.

See TEXTSCREEN .


Next: , Previous: , Up: TURTLE AND WINDOW CONTROL   [Contents][Index]

setscrunch

SETSCRUNCH xscale yscale

adjusts the aspect ratio and scaling of the graphics display. After this command is used, all further turtle motion will be adjusted by multiplying the horizontal and vertical extent of the motion by the two numbers given as inputs. For example, after the instruction SETSCRUNCH 2 1 motion at a heading of 45 degrees will move twice as far horizontally as vertically. If your squares don’t come out square, try this. (Alternatively, you can deliberately misadjust the aspect ratio to draw an ellipse.)

For all modern computers, both scale factors are initially 1. For DOS machines, the scale factors are initially set according to what the hardware claims the aspect ratio is, but the hardware sometimes lies. For DOS, the values set by SETSCRUNCH are remembered in a file (called scrunch.dat) and are automatically put into effect when a Logo session begins.


Next: , Previous: , Up: TURTLE AND WINDOW CONTROL   [Contents][Index]

refresh

REFRESH

(command) tells Logo to remember the turtle’s motions so that they can be used for high-resolution printing (wxWidgets) or to refresh the graphics window if it is moved, resized, or overlayed (non-wxWidgets). This is the default.


Previous: , Up: TURTLE AND WINDOW CONTROL   [Contents][Index]

norefresh

NOREFRESH

(command) tells Logo not to remember the turtle’s motions, which may be useful to save time and memory if your program is interactive or animated, rather than drawing a static picture you’ll want to print later (wxWidgets). In non-wxWidgets versions, using NOREFRESH may prevent Logo from restoring the graphics image after the window is moved, resized, or overlayed.


Next: , Previous: , Up: GRAPHICS   [Contents][Index]

7.4 Turtle and Window Queries


Next: , Previous: , Up: TURTLE AND WINDOW QUERIES   [Contents][Index]

shownp

SHOWNP
SHOWN?

outputs TRUE if the turtle is shown (visible), FALSE if the turtle is hidden. See SHOWTURTLE and HIDETURTLE.

See SHOWTURTLE , HIDETURTLE .


Next: , Previous: , Up: TURTLE AND WINDOW QUERIES   [Contents][Index]

screenmode

SCREENMODE

outputs the word TEXTSCREEN, SPLITSCREEN, or FULLSCREEN depending on the current screen mode.


Next: , Previous: , Up: TURTLE AND WINDOW QUERIES   [Contents][Index]

turtlemode

TURTLEMODE

outputs the word WRAP, FENCE, or WINDOW depending on the current turtle mode.


Previous: , Up: TURTLE AND WINDOW QUERIES   [Contents][Index]

labelsize

LABELSIZE

(wxWidgets only) outputs a list of two positive integers, the width and height of characters displayed by LABEL measured in turtle steps (which will be different from screen pixels if SETSCRUNCH has been used). There is no SETLABELSIZE because the width and height of a font are not separately controllable, so the inverse of this operation is SETLABELHEIGHT, which takes just one number for the desired height.


Next: , Previous: , Up: GRAPHICS   [Contents][Index]

7.5 Pen and Background Control

The turtle carries a pen that can draw pictures. At any time the pen can be UP (in which case moving the turtle does not change what’s on the graphics screen) or DOWN (in which case the turtle leaves a trace). If the pen is down, it can operate in one of three modes: PAINT (so that it draws lines when the turtle moves), ERASE (so that it erases any lines that might have been drawn on or through that path earlier), or REVERSE (so that it inverts the status of each point along the turtle’s path).


Next: , Previous: , Up: PEN AND BACKGROUND CONTROL   [Contents][Index]

pendown

PENDOWN
PD

sets the pen’s position to DOWN, without changing its mode.


Next: , Previous: , Up: PEN AND BACKGROUND CONTROL   [Contents][Index]

penup

PENUP
PU

sets the pen’s position to UP, without changing its mode.


Next: , Previous: , Up: PEN AND BACKGROUND CONTROL   [Contents][Index]

penpaint

PENPAINT
PPT

sets the pen’s position to DOWN and mode to PAINT.


Next: , Previous: , Up: PEN AND BACKGROUND CONTROL   [Contents][Index]

penerase

PENERASE
PE

sets the pen’s position to DOWN and mode to ERASE.


Next: , Previous: , Up: PEN AND BACKGROUND CONTROL   [Contents][Index]

penreverse

PENREVERSE
PX

sets the pen’s position to DOWN and mode to REVERSE. (This may interact in system-dependent ways with use of color.)


Next: , Previous: , Up: PEN AND BACKGROUND CONTROL   [Contents][Index]

setpencolor

SETPENCOLOR colornumber.or.rgblist
SETPC colornumber.or.rgblist

sets the pen color to the given number, which must be a nonnegative integer. There are initial assignments for the first 16 colors:

 0  black	 1  blue	 2  green	 3  cyan
 4  red		 5  magenta	 6  yellow	 7 white
 8  brown	 9  tan		10  forest	11  aqua
12  salmon	13  purple	14  orange	15  grey

but other colors can be assigned to numbers by the PALETTE command. Alternatively, sets the pen color to the given RGB values (a list of three nonnegative numbers less than 100 specifying the percent saturation of red, green, and blue in the desired color).


Next: , Previous: , Up: PEN AND BACKGROUND CONTROL   [Contents][Index]

setpalette

SETPALETTE colornumber rgblist

sets the actual color corresponding to a given number, if allowed by the hardware and operating system. Colornumber must be an integer greater than or equal to 8. (Logo tries to keep the first 8 colors constant.) The second input is a list of three nonnegative numbers less than 100 specifying the percent saturation of red, green, and blue in the desired color.


Next: , Previous: , Up: PEN AND BACKGROUND CONTROL   [Contents][Index]

setpensize

SETPENSIZE size

sets the thickness of the pen. The input is either a single positive integer or a list of two positive integers (for horizontal and vertical thickness). Some versions pay no attention to the second number, but always have a square pen.


Next: , Previous: , Up: PEN AND BACKGROUND CONTROL   [Contents][Index]

setpenpattern

SETPENPATTERN pattern

sets hardware-dependent pen characteristics. This command is not guaranteed compatible between implementations on different machines.


Next: , Previous: , Up: PEN AND BACKGROUND CONTROL   [Contents][Index]

setpen

SETPEN list					(library procedure)

sets the pen’s position, mode, thickness, and hardware-dependent characteristics according to the information in the input list, which should be taken from an earlier invocation of PEN.

See PEN .


Previous: , Up: PEN AND BACKGROUND CONTROL   [Contents][Index]

setbackground

SETBACKGROUND colornumber.or.rgblist
SETBG colornumber.or.rgblist

set the screen background color by slot number or RGB values. See SETPENCOLOR for details.

See SETPENCOLOR .


Next: , Previous: , Up: GRAPHICS   [Contents][Index]

7.6 Pen Queries


Next: , Previous: , Up: PEN QUERIES   [Contents][Index]

pendownp

PENDOWNP
PENDOWN?

outputs TRUE if the pen is down, FALSE if it’s up.


Next: , Previous: , Up: PEN QUERIES   [Contents][Index]

penmode

PENMODE

outputs one of the words PAINT, ERASE, or REVERSE according to the current pen mode.


Next: , Previous: , Up: PEN QUERIES   [Contents][Index]

pencolor

PENCOLOR
PC

outputs a color number, a nonnegative integer that is associated with a particular color, or a list of RGB values if such a list was used as the most recent input to SETPENCOLOR. There are initial assignments for the first 16 colors:

 0  black        1  blue         2  green        3  cyan
 4  red          5  magenta      6  yellow       7 white
 8  brown        9  tan         10  forest      11  aqua
12  salmon      13  purple      14  orange      15  grey

but other colors can be assigned to numbers by the PALETTE command.


Next: , Previous: , Up: PEN QUERIES   [Contents][Index]

palette

PALETTE colornumber

outputs a list of three nonnegative numbers less than 100 specifying the percent saturation of red, green, and blue in the color associated with the given number.


Next: , Previous: , Up: PEN QUERIES   [Contents][Index]

pensize

PENSIZE

outputs a list of two positive integers, specifying the horizontal and vertical thickness of the turtle pen. (In some implementations, including wxWidgets, the two numbers are always equal.)

PENPATTERN

outputs system-specific pen information.


Next: , Previous: , Up: PEN QUERIES   [Contents][Index]

pen

PEN						(library procedure)

outputs a list containing the pen’s position, mode, thickness, and hardware-specific characteristics, for use by SETPEN.

See SETPEN .


Previous: , Up: PEN QUERIES   [Contents][Index]

background

BACKGROUND
BG

outputs the graphics background color, either as a slot number or as an RGB list, whichever way it was set. (See PENCOLOR.)


Next: , Previous: , Up: GRAPHICS   [Contents][Index]

7.7 Saving and Loading Pictures


Next: , Previous: , Up: SAVING AND LOADING PICTURES   [Contents][Index]

savepict

SAVEPICT filename

command. Writes a file with the specified name containing the state of the graphics window, including any nonstandard color palette settings, in Logo’s internal format. This picture can be restored to the screen using LOADPICT. The format is not portable between platforms, nor is it readable by other programs. EPSPICT to export Logo graphics for other programs.


Next: , Previous: , Up: SAVING AND LOADING PICTURES   [Contents][Index]

loadpict

LOADPICT filename

command. Reads the specified file, which must have been written by a SAVEPICT command, and restores the graphics window and color palette settings to the values stored in the file. Any drawing previously on the screen is cleared.

See SAVEPICT .


Previous: , Up: SAVING AND LOADING PICTURES   [Contents][Index]

epspict

EPSPICT filename

command. Writes a file with the specified name, containing an Encapsulated Postscript (EPS) representation of the state of the graphics window. This file can be imported into other programs that understand EPS format. Restrictions: the drawing cannot use FILL, PENERASE, or PENREVERSE; any such instructions will be ignored in the translation to Postscript form.


Previous: , Up: GRAPHICS   [Contents][Index]

7.8 Mouse Queries


Next: , Previous: , Up: MOUSE QUERIES   [Contents][Index]

mousepos

MOUSEPOS

outputs the coordinates of the mouse, provided that it’s within the graphics window, in turtle coordinates. If the mouse is outside the graphics window, then the last position within the window is returned. Exception: If a mouse button is pressed within the graphics window and held while the mouse is dragged outside the window, the mouse’s position is returned as if the window were big enough to include it.


Next: , Previous: , Up: MOUSE QUERIES   [Contents][Index]

clickpos

CLICKPOS

outputs the coordinates that the mouse was at when a mouse button was most recently pushed, provided that that position was within the graphics window, in turtle coordinates. (wxWidgets only)


Next: , Previous: , Up: MOUSE QUERIES   [Contents][Index]

buttonp

BUTTONP
BUTTON?

outputs TRUE if a mouse button is down and the mouse is over the graphics window. Once the button is down, BUTTONP remains true until the button is released, even if the mouse is dragged out of the graphics window.


Previous: , Up: MOUSE QUERIES   [Contents][Index]

button

BUTTON

outputs 0 if no mouse button has been pushed inside the Logo window since the last call to BUTTON. Otherwise, it outputs an integer between 1 and 3 indicating which button was most recently pressed. Ordinarily 1 means left, 2 means right, and 3 means center, but operating systems may reconfigure these.


Next: , Previous: , Up: Top   [Contents][Index]

8 Workspace Management


Next: , Previous: , Up: WORKSPACE MANAGEMENT   [Contents][Index]

8.1 Procedure Definition


Next: , Previous: , Up: PROCEDURE DEFINITION   [Contents][Index]

to

TO procname :input1 :input2 ...			(special form)

command. Prepares Logo to accept a procedure definition. The procedure will be named procname and there must not already be a procedure by that name. The inputs will be called input1 etc. Any number of inputs are allowed, including none. Names of procedures and inputs are case-insensitive.

Unlike every other Logo procedure, TO takes as its inputs the actual words typed in the instruction line, as if they were all quoted, rather than the results of evaluating expressions to provide the inputs. (That’s what special form means.)

This version of Logo allows variable numbers of inputs to a procedure. After the procedure name come four kinds of things, in this order:

    1.   0 or more REQUIRED inputs    :FOO :FROBOZZ
    2.   0 or more OPTIONAL inputs    [:BAZ 87] [:THINGO 5+9]
    3.   0 or 1 REST input            [:GARPLY]
    4.   0 or 1 DEFAULT number        5

Every procedure has a minimum, default, and maximum number of inputs. (The latter can be infinite.)

The minimum number of inputs is the number of required inputs, which must come first. A required input is indicated by the

:inputname

notation.

After all the required inputs can be zero or more optional inputs, each of which is represented by the following notation:

[:inputname default.value.expression]

When the procedure is invoked, if actual inputs are not supplied for these optional inputs, the default value expressions are evaluated to set values for the corresponding input names. The inputs are processed from left to right, so a default value expression can be based on earlier inputs. Example:

to proc :inlist [:startvalue first :inlist]

If the procedure is invoked by saying

proc [a b c]

then the variable inlist will have the value [A B C] and the variable startvalue will have the value A. If the procedure is invoked by saying

(proc [a b c] "x)

then inlist will have the value [A B C] and startvalue will have the value X.

After all the required and optional input can come a single rest input, represented by the following notation:

[:inputname]

This is a rest input rather than an optional input because there is no default value expression. There can be at most one rest input. When the procedure is invoked, the value of this inputname will be a list containing all of the actual inputs provided that were not used for required or optional inputs. Example:

to proc :in1 [:in2 "foo] [:in3 "baz] [:in4]

If this procedure is invoked by saying

proc "x

then in1 has the value X, in2 has the value FOO, in3 has the value BAZ, and in4 has the value [] (the empty list). If it’s invoked by saying

(proc "a "b "c "d "e)

then in1 has the value A, in2 has the value B, in3 has the value C, and in4 has the value [D E].

The maximum number of inputs for a procedure is infinite if a rest input is given; otherwise, it is the number of required inputs plus the number of optional inputs.

The default number of inputs for a procedure, which is the number of inputs that it will accept if its invocation is not enclosed in parentheses, is ordinarily equal to the minimum number. If you want a different default number you can indicate that by putting the desired default number as the last thing on the TO line. example:

to proc :in1 [:in2 "foo] [:in3] 3

This procedure has a minimum of one input, a default of three inputs, and an infinite maximum.

Logo responds to the TO command by entering procedure definition mode. The prompt character changes from ? to > and whatever instructions you type become part of the definition until you type a line containing only the word END.


Next: , Previous: , Up: PROCEDURE DEFINITION   [Contents][Index]

define

DEFINE procname text

command. Defines a procedure with name procname and text text. If there is already a procedure with the same name, the new definition replaces the old one. The text input must be a list whose members are lists. The first member is a list of inputs; it looks like a TO line but without the word TO, without the procedure name, and without the colons before input names. In other words, the members of this first sublist are words for the names of required inputs and lists for the names of optional or rest inputs. The remaining sublists of the text input make up the body of the procedure, with one sublist for each instruction line of the body. (There is no END line in the text input.) It is an error to redefine a primitive procedure unless the variable REDEFP has the value TRUE.

See REDEFP .


Next: , Previous: , Up: PROCEDURE DEFINITION   [Contents][Index]

text

TEXT procname

outputs the text of the procedure named procname in the form expected by DEFINE: a list of lists, the first of which describes the inputs to the procedure and the rest of which are the lines of its body. The text does not reflect formatting information used when the procedure was defined, such as continuation lines and extra spaces.


Next: , Previous: , Up: PROCEDURE DEFINITION   [Contents][Index]

fulltext

FULLTEXT procname

outputs a representation of the procedure procname in which formatting information is preserved. If the procedure was defined with TO, EDIT, or LOAD, then the output is a list of words. Each word represents one entire line of the definition in the form output by READWORD, including extra spaces and continuation lines. The last member of the output represents the END line. If the procedure was defined with DEFINE, then the output is a list of lists. If these lists are printed, one per line, the result will look like a definition using TO. Note: the output from FULLTEXT is not suitable for use as input to DEFINE!

See TEXT.


Previous: , Up: PROCEDURE DEFINITION   [Contents][Index]

copydef

COPYDEF newname oldname

command. Makes newname a procedure identical to oldname. The latter may be a primitive. If newname was already defined, its previous definition is lost. If newname was already a primitive, the redefinition is not permitted unless the variable REDEFP has the value TRUE.

Note: dialects of Logo differ as to the order of inputs to COPYDEF. This dialect uses "MAKE order," not "NAME order."

See REDEFP , SAVE , PO , POT .


Next: , Previous: , Up: WORKSPACE MANAGEMENT   [Contents][Index]

8.2 Variable Definition


Next: , Previous: , Up: VARIABLE DEFINITION   [Contents][Index]

make

MAKE varname value

command. Assigns the value value to the variable named varname, which must be a word. Variable names are case-insensitive. If a variable with the same name already exists, the value of that variable is changed. If not, a new global variable is created.


Next: , Previous: , Up: VARIABLE DEFINITION   [Contents][Index]

name

NAME value varname				(library procedure)

command. Same as MAKE but with the inputs in reverse order.


Next: , Previous: , Up: VARIABLE DEFINITION   [Contents][Index]

local

LOCAL varname
LOCAL varnamelist
(LOCAL varname1 varname2 ...)

command. Accepts as inputs one or more words, or a list of words. A variable is created for each of these words, with that word as its name. The variables are local to the currently running procedure. Logo variables follow dynamic scope rules; a variable that is local to a procedure is available to any subprocedure invoked by that procedure. The variables created by LOCAL have no initial value; they must be assigned a value (e.g., with MAKE) before the procedure attempts to read their value.

See MAKE .


Next: , Previous: , Up: VARIABLE DEFINITION   [Contents][Index]

localmake

LOCALMAKE varname value				(library procedure)

command. Makes the named variable local, like LOCAL, and assigns it the given value, like MAKE.

See LOCAL , See MAKE .


Next: , Previous: , Up: VARIABLE DEFINITION   [Contents][Index]

thing

THING varname
:quoted.varname

outputs the value of the variable whose name is the input. If there is more than one such variable, the innermost local variable of that name is chosen. The colon notation is an abbreviation not for THING but for the combination

thing "

so that :FOO means THING "FOO.


Previous: , Up: VARIABLE DEFINITION   [Contents][Index]

global

GLOBAL varname
GLOBAL varnamelist
(GLOBAL varname1 varname2 ...)

command. Accepts as inputs one or more words, or a list of words. A global variable is created for each of these words, with that word as its name. The only reason this is necessary is that you might want to use the "setter" notation SETXYZ for a variable XYZ that does not already have a value; GLOBAL "XYZ makes that legal. Note: If there is currently a local variable of the same name, this command does *not* make Logo use the global value instead of the local one.


Next: , Previous: , Up: WORKSPACE MANAGEMENT   [Contents][Index]

8.3 Property Lists

Note: Names of property lists are always case-insensitive. Names of individual properties are case-sensitive or case-insensitive depending on the value of CASEIGNOREDP, which is TRUE by default.

See CASEIGNOREDP .

In principle, every possible name is the name of a property list, which is initially empty. So Logo never gives a "no such property list" error, as it would for undefined procedure or variable names. But the primitive procedures that deal with "all" property lists (CONTENTS, PLISTS, etc.) list only nonempty ones. To "erase" a property list ERASE means to make it empty, removing all properties from it.


Next: , Previous: , Up: PROPERTY LISTS   [Contents][Index]

pprop

PPROP plistname propname value

command. Adds a property to the plistname property list with name propname and value value.


Next: , Previous: , Up: PROPERTY LISTS   [Contents][Index]

gprop

GPROP plistname propname

outputs the value of the propname property in the plistname property list, or the empty list if there is no such property.


Next: , Previous: , Up: PROPERTY LISTS   [Contents][Index]

remprop

REMPROP plistname propname

command. Removes the property named propname from the property list named plistname.


Previous: , Up: PROPERTY LISTS   [Contents][Index]

plist

PLIST plistname

outputs a list whose odd-numbered members are the names, and whose even-numbered members are the values, of the properties in the property list named plistname. The output is a copy of the actual property list; changing properties later will not magically change a list output earlier by PLIST.


Next: , Previous: , Up: WORKSPACE MANAGEMENT   [Contents][Index]

8.4 Workspace Predicates


Next: , Previous: , Up: WORKSPACE PREDICATES   [Contents][Index]

procedurep

PROCEDUREP name
PROCEDURE? name

outputs TRUE if the input is the name of a procedure.


Next: , Previous: , Up: WORKSPACE PREDICATES   [Contents][Index]

primitivep

PRIMITIVEP name
PRIMITIVE? name

outputs TRUE if the input is the name of a primitive procedure (one built into Logo). Note that some of the procedures described in this document are library procedures, not primitives.


Next: , Previous: , Up: WORKSPACE PREDICATES   [Contents][Index]

definedp

DEFINEDP name
DEFINED? name

outputs TRUE if the input is the name of a user-defined procedure, including a library procedure.


Next: , Previous: , Up: WORKSPACE PREDICATES   [Contents][Index]

namep

NAMEP name
NAME? name

outputs TRUE if the input is the name of a variable.


Previous: , Up: WORKSPACE PREDICATES   [Contents][Index]

plistp

PLISTP name
PLIST? name

outputs TRUE if the input is the name of a nonempty property list. (In principle every word is the name of a property list; if you haven’t put any properties in it, PLIST of that name outputs an empty list, rather than giving an error message.)


Next: , Previous: , Up: WORKSPACE MANAGEMENT   [Contents][Index]

8.5 Workspace Queries

Note: All procedures whose input is indicated as contentslist will accept a single word (taken as a procedure name), a list of words (taken as names of procedures), or a list of three lists as described under the CONTENTS command above.


Next: , Previous: , Up: WORKSPACE QUERIES   [Contents][Index]

contents

CONTENTS

outputs a "contents list," i.e., a list of three lists containing names of defined procedures, variables, and property lists respectively. This list includes all unburied named items in the workspace.


Next: , Previous: , Up: WORKSPACE QUERIES   [Contents][Index]

buried

BURIED

outputs a contents list including all buried named items in the workspace.


Next: , Previous: , Up: WORKSPACE QUERIES   [Contents][Index]

traced

TRACED

outputs a contents list including all traced named items in the workspace.


Next: , Previous: , Up: WORKSPACE QUERIES   [Contents][Index]

stepped

STEPPED

outputs a contents list including all stepped named items in the workspace.


Next: , Previous: , Up: WORKSPACE QUERIES   [Contents][Index]

procedures

PROCEDURES

outputs a list of the names of all unburied user-defined procedures in the workspace. Note that this is a list of names, not a contents list. (However, procedures that require a contents list as input will accept this list.)


Next: , Previous: , Up: WORKSPACE QUERIES   [Contents][Index]

primitives

PRIMITIVES

outputs a list of the names of all primitive procedures in the workspace. Note that this is a list of names, not a contents list. (However, procedures that require a contents list as input will accept this list.)


Next: , Previous: , Up: WORKSPACE QUERIES   [Contents][Index]

names

NAMES

outputs a contents list consisting of an empty list (indicating no procedure names) followed by a list of all unburied variable names in the workspace.


Next: , Previous: , Up: WORKSPACE QUERIES   [Contents][Index]

plists

PLISTS

outputs a contents list consisting of two empty lists (indicating no procedures or variables) followed by a list of all unburied nonempty property lists in the workspace.


Next: , Previous: , Up: WORKSPACE QUERIES   [Contents][Index]

namelist

NAMELIST varname				(library procedure)
NAMELIST varnamelist

outputs a contents list consisting of an empty list followed by a list of the name or names given as input. This is useful in conjunction with workspace control procedures that require a contents list as input.


Next: , Previous: , Up: WORKSPACE QUERIES   [Contents][Index]

pllist

PLLIST plname					(library procedure)
PLLIST plnamelist

outputs a contents list consisting of two empty lists followed by a list of the name or names given as input. This is useful in conjunction with workspace control procedures that require a contents list as input.

See CONTENTS .


Next: , Previous: , Up: WORKSPACE QUERIES   [Contents][Index]

arity

ARITY procedurename

outputs a list of three numbers: the minimum, default, and maximum number of inputs for the procedure whose name is the input. It is an error if there is no such procedure. A maximum of -1 means that the number of inputs is unlimited.


Previous: , Up: WORKSPACE QUERIES   [Contents][Index]

nodes

NODES

outputs a list of two numbers. The first represents the number of nodes of memory currently in use. The second shows the maximum number of nodes that have been in use at any time since the last invocation of NODES. (A node is a small block of computer memory as used by Logo. Each number uses one node. Each non-numeric word uses one node, plus some non-node memory for the characters in the word. Each array takes one node, plus some non-node memory, as well as the memory required by its elements. Each list requires one node per element, as well as the memory within the elements.) If you want to track the memory use of an algorithm, it is best if you invoke GC at the beginning of each iteration, since otherwise the maximum will include storage that is unused but not yet collected.


Next: , Previous: , Up: WORKSPACE MANAGEMENT   [Contents][Index]

8.6 Workspace Inspection


Next: , Previous: , Up: WORKSPACE INSPECTION   [Contents][Index]

po

PRINTOUT contentslist
PO contentslist

command. Prints to the write stream the definitions of all procedures, variables, and property lists named in the input contents list.


Next: , Previous: , Up: WORKSPACE INSPECTION   [Contents][Index]

poall

POALL						(library procedure)

command. Prints all unburied definitions in the workspace. Abbreviates PO CONTENTS.

See CONTENTS .


Next: , Previous: , Up: WORKSPACE INSPECTION   [Contents][Index]

pops

POPS						(library procedure)

command. Prints the definitions of all unburied procedures in the workspace. Abbreviates PO PROCEDURES.

See PO , PROCEDURES .


Next: , Previous: , Up: WORKSPACE INSPECTION   [Contents][Index]

pons

PONS						(library procedure)

command. Prints the definitions of all unburied variables in the workspace. Abbreviates PO NAMES.

See PO , NAMES .


Next: , Previous: , Up: WORKSPACE INSPECTION   [Contents][Index]

popls

POPLS						(library procedure)

command. Prints the contents of all unburied nonempty property lists in the workspace. Abbreviates PO PLISTS.

See PO , PLISTS .


Next: , Previous: , Up: WORKSPACE INSPECTION   [Contents][Index]

pon

PON varname					(library procedure)
PON varnamelist

command. Prints the definitions of the named variable(s).
Abbreviates PO NAMELIST varname(list).

See PO , NAMELIST .


Next: , Previous: , Up: WORKSPACE INSPECTION   [Contents][Index]

popl

POPL plname					(library procedure)
POPL plnamelist

command. Prints the definitions of the named property list(s).
Abbreviates PO PLLIST plname(list).

See PO , PLLIST .


Next: , Previous: , Up: WORKSPACE INSPECTION   [Contents][Index]

pot

POT contentslist

command. Prints the title lines of the named procedures and the definitions of the named variables and property lists. For property lists, the entire list is shown on one line instead of as a series of PPROP instructions as in PO.

See PPROP , PO .


Previous: , Up: WORKSPACE INSPECTION   [Contents][Index]

pots

POTS						(library procedure)

command. Prints the title lines of all unburied procedures in the workspace. Abbreviates POT PROCEDURES.

See PROCEDURES .


Previous: , Up: WORKSPACE MANAGEMENT   [Contents][Index]

8.7 Workspace Control


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

erase

ERASE contentslist
ER contentslist

command. Erases from the workspace the procedures, variables, and property lists named in the input. Primitive procedures may not be erased unless the variable REDEFP has the value TRUE.

See REDEFP .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

erall

ERALL

command. Erases all unburied procedures, variables, and property lists from the workspace. Abbreviates ERASE CONTENTS.

See CONTENTS .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

erps

ERPS

command. Erases all unburied procedures from the workspace.
Abbreviates ERASE PROCEDURES.

See ERASE , PROCEDURES .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

erns

ERNS

command. Erases all unburied variables from the workspace. Abbreviates ERASE NAMES.

See ERASE , NAMES .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

erpls

ERPLS

command. Erases all unburied property lists from the workspace.
Abbreviates ERASE PLISTS.

See ERASE , PLISTS .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

ern

ERN varname					(library procedure)
ERN varnamelist

command. Erases from the workspace the variable(s) named in the input. Abbreviates ERASE NAMELIST varname(list).

See ERASE , NAMELIST .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

erpl

ERPL plname					(library procedure)
ERPL plnamelist

command. Erases from the workspace the property list(s) named in the input. Abbreviates ERASE PLLIST plname(list).

See ERASE , PLLIST .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

bury

BURY contentslist

command. Buries the procedures, variables, and property lists named in the input. A buried item is not included in the lists output by CONTENTS, PROCEDURES, VARIABLES, and PLISTS, but is included in the list output by BURIED. By implication, buried things are not printed by POALL or saved by SAVE.

See CONTENTS , PROCEDURES , PONS , PLISTS , POALL , SAVE .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

buryall

BURYALL                                         (library procedure)

command. Abbreviates BURY CONTENTS.

See CONTENTS .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

buryname

BURYNAME varname				(library procedure)
BURYNAME varnamelist

command. Abbreviates BURY NAMELIST varname(list).

See BURY , NAMELIST .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

unbury

UNBURY contentslist

command. Unburies the procedures, variables, and property lists named in the input. That is, the named items will be returned to view in CONTENTS, etc.

See CONTENTS .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

unburyall

UNBURYALL					(library procedure)

command. Abbreviates UNBURY BURIED.

See BURIED .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

unburyname

UNBURYNAME varname				(library procedure)
UNBURYNAME varnamelist

command. Abbreviates UNBURY NAMELIST varname(list).

See UNBURY , NAMELIST .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

buriedp

BURIEDP contentslist
BURIED? contentslist

outputs TRUE if the first procedure, variable, or property list named in the contents list is buried, FALSE if not. Only the first thing in the list is tested; the most common use will be with a word as input, naming a procedure, but a contents list is allowed so that you can BURIEDP [[] [variable]] or BURIEDP [[] [] [proplist]].


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

trace

TRACE contentslist

command. Marks the named items for tracing. A message is printed whenever a traced procedure is invoked, giving the actual input values, and whenever a traced procedure STOPs or OUTPUTs. A message is printed whenever a new value is assigned to a traced variable using MAKE. A message is printed whenever a new property is given to a traced property list using PPROP.

See STOP , OUTPUT , MAKE , PPROP .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

untrace

UNTRACE contentslist

command. Turns off tracing for the named items.


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

tracedp

TRACEDP contentslist
TRACED? contentslist

outputs TRUE if the first procedure, variable, or property list named in the contents list is traced, FALSE if not. Only the first thing in the list is tested; the most common use will be with a word as input, naming a procedure, but a contents list is allowed so that you can TRACEDP [[] [variable]] or TRACEDP [[] [] [proplist]].


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

step

STEP contentslist

command. Marks the named items for stepping. Whenever a stepped procedure is invoked, each instruction line in the procedure body is printed before being executed, and Logo waits for the user to type a newline at the terminal. A message is printed whenever a stepped variable name is shadowed because a local variable of the same name is created either as a procedure input or by the LOCAL command.

See LOCAL .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

unstep

UNSTEP contentslist

command. Turns off stepping for the named items.


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

steppedp

STEPPEDP contentslist
STEPPED? contentslist

outputs TRUE if the first procedure, variable, or property list named in the contents list is stepped, FALSE if not. Only the first thing in the list is tested; the most common use will be with a word as input, naming a procedure, but a contents list is allowed so that you can STEPPEDP [[] [variable]] or STEPPEDP [[] [] [proplist]].


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

edit

EDIT contentslist
ED contentslist
(EDIT)
(ED)

command. If invoked with an input, EDIT writes the definitions of the named items into a temporary file and edits that file, using an editor that depends on the platform you’re using. In wxWidgets, and in the MacOS Classic version, there is an editor built into Logo. In the non-wxWidgets versions for Unix, MacOS X, Windows, and DOS, Logo uses your favorite editor as determined by the EDITOR environment variable. If you don’t have an EDITOR variable, edits the definitions using jove. If invoked without an input, EDIT edits the same file left over from a previous EDIT or EDITFILE instruction. When you leave the editor, Logo reads the revised definitions and modifies the workspace accordingly. It is not an error if the input includes names for which there is no previous definition.

If there is a variable LOADNOISILY whose value is TRUE, then, after leaving the editor, TO commands in the temporary file print ‘procname defined’ (where procname is the name of the procedure being defined); if LOADNOISILY is FALSE or undefined, TO commands in the file are carried out silently.

If there is an environment variable called TEMP, then Logo uses its value as the directory in which to write the temporary file used for editing.

Exceptionally, the EDIT command can be used without its default input and without parentheses provided that nothing follows it on the instruction line.

See LOADNOISILY , See EDITFILE .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

editfile

EDITFILE filename

command. Starts the Logo editor, like EDIT, but instead of editing a temporary file it edits the file specified by the input. When you leave the editor, Logo reads the revised file, as for EDIT. EDITFILE also remembers the filename, so that a subsequent EDIT command with no input will re-edit the same file.

EDITFILE is intended as an alternative to LOAD and SAVE. You can maintain a workspace file yourself, controlling the order in which definitions appear, maintaining comments in the file, and so on.

In the wxWidgets version, EDITFILE asks whether or not you want to load the file into Logo when you finish editing. This allows you to use EDITFILE to edit data files without leaving Logo.


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

edall

EDALL						(library procedure)

command. Abbreviates EDIT CONTENTS.

See CONTENTS .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

edps

EDPS						(library procedure)

command. Abbreviates EDIT PROCEDURES.

See EDIT , PROCEDURES .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

edns

EDNS						(library procedure)

command. Abbreviates EDIT NAMES.

See EDIT , NAMES .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

edpls

EDPLS						(library procedure)

command. Abbreviates EDIT PLISTS.

See EDIT , PLISTS .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

edn

EDN varname					(library procedure)
EDN varnamelist

command. Abbreviates EDIT NAMELIST varname(list).

See EDIT , NAMELIST .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

edpl

EDPL plname					(library procedure)
EDPL plnamelist

command. Abbreviates EDIT PLLIST plname(list).

See EDIT , PLLIST .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

save

SAVE filename

command. Saves the definitions of all unburied procedures, variables, and nonempty property lists in the named file. Equivalent to

to save :filename
local "oldwriter
make "oldwriter writer
openwrite :filename
setwrite :filename
poall
setwrite :oldwriter
close :filename
end

Exceptionally, SAVE can be used with no input and without parentheses if it is the last thing on the command line. In this case, the filename from the most recent LOAD or SAVE command will be used. (It is an error if there has been no previous LOAD or SAVE.)


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

savel

SAVEL contentslist filename			(library procedure)

command. Saves the definitions of the procedures, variables, and property lists specified by contentslist to the file named filename.


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

load

LOAD filename

command. Reads instructions from the named file and executes them. The file can include procedure definitions with TO, and these are accepted even if a procedure by the same name already exists. If the file assigns a list value to a variable named STARTUP, then that list is run as an instructionlist after the file is loaded. If there is a variable LOADNOISILY whose value is TRUE, then TO commands in the file print ‘procname defined’ (where procname is the name of the procedure being defined); if LOADNOISILY is FALSE or undefined, TO commands in the file are carried out silently.

See STARTUP , See LOADNOISILY .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

cslsload

CSLSLOAD name

command. Loads the named file, like LOAD, but from the directory containing the Computer Science Logo Style programs instead of the current user’s directory.

See LOAD .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

help

HELP name
(HELP)

command. Prints information from the reference manual about the primitive procedure named by the input. With no input, lists all the primitives about which help is available. If there is an environment variable LOGOHELP, then its value is taken as the directory in which to look for help files, instead of the default help directory.

If HELP is called with the name of a defined procedure for which there is no help file, it will print the title line of the procedure followed by lines from the procedure body that start with semicolon, stopping when a non-semicolon line is seen.

Exceptionally, the HELP command can be used without its default input and without parentheses provided that nothing follows it on the instruction line.


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

seteditor

SETEDITOR path

command. Tells Logo to use the specified program as its editor instead of the default editor. The format of a path depends on your operating system.


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

setlibloc

SETLIBLOC path

command. Tells Logo to use the specified directory as its library instead of the default. (Note that many Logo "primitive" procedures are actually found in the library, so they may become unavailable if your new library does not include them!) The format of a path depends on your operating system.


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][Index]

setcslsloc

SETCSLSLOC path

command. Tells Logo to use the specified directory for the CSLSLOAD command, instead of the default directory. The format of a path depends on your operating system.

See CSLSLOAD .


Next: , Previous: , Up: WORKSPACE CONTROL   [Contents][<