Go to the first, previous, next, last section, table of contents.


Communication

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 section printdepthlimit ; section printwidthlimit

print

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

command. Prints the input or inputs to the current write stream (initially the terminal). 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.

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 terminal 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 section setcursor ; section wait

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 section print

Receivers

readlist

READLIST
RL

reads a line from the read stream (initially the terminal) 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.

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, but the character following the backslash has 128 added to its representation. Programs can use BACKSLASHEDP to check for this code. (Backslashedness is preserved only for certain characters.)

See section backslashedp

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 a terminal, 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 section readlist

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 a terminal, 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 section readlist ; section readword

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 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.

The Macintosh, of course, is not programmable.

File Access

openread

OPENREAD filename

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

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.

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.

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 section reader ; section writer ; section setreadpos ; section setwritepos

close

CLOSE filename

command. Closes the named file.

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.

closeall

CLOSEALL					(library procedure)

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

See section foreach ; section close

erasefile

ERASEFILE filename
ERF filename

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

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 section openwrite ; section writer

nodribble

NODRIBBLE

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

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 terminal, 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 section readlist ; section openread ; section openupdate

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 terminal, 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.

See section print ; section openwrite ; section openappend ; section openupdate

reader

READER

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

writer

WRITER

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

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 terminal.

See section readlist

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 terminal.

See section print

readpos

READPOS

outputs the file position of the current read stream file.

writepos

WRITEPOS

outputs the file position of the current write stream file.

eofp

EOFP
EOF?

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

filep

FILEP filename
FILE? filename					(library procedure)

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

Terminal Access

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 section eofp ; section readlist

cleartext

CLEARTEXT
CT

command. Clears the text screen of the terminal.

setcursor

SETCURSOR vector

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

cursor

CURSOR

outputs a list containing the current x and y coordinates of the screen 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 terminal strangely.

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 section setcursor

settextcolor

SETTEXTCOLOR foreground background
SETTC foreground background

Command (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 section standout


Go to the first, previous, next, last section, table of contents.