DRLRM6.WS4 (= "Dr. Logo Reference Manual", Section 6)
----------
(Retyped by Emmanuel ROCHE.)
ROCHE> Since only the CP/M-86 version of "Dr. Logo for the ACT Apricot F1"
computer has been found, I have retyped only the documentation of the
primitives contained in this version, not the explanations of all the
primitives of the original copy-protected Dr. Logo, which can format floppy
disks, copy full disks, etc (like computers with BASIC in ROM, which have no
separate Operating Systems).
Section 6: References to primitives
-----------------------------------
This section defines the Dr. Logo primitives. The description of each
primitive is presented in the following form:
Action
======
Quickly tells what the primitive does.
Syntax
======
Shows the correct way to enter an expression using the primitive. If you can
use an abbreviation for the primitive name, the abbreviation appears on the
second line.
Do not enter a command that is identical to the syntax line! The syntax line
usually contains symbols that Dr. Logo does not recognize. By using these
symbols, the syntax line can represent the wide variety of expressions that
you can enter using the primitive.
The syntax line uses two kinds of symbols to show you how to enter an
expression. Typographical symbols tell you how many times you can enter an
input. Input symbols tell what kind of object the primitive can accept as
input. The typographical symbols are
ellipsis: (...)
---------------
Means that the primitive can accept a variable number of inputs; that is to
say, you can use parentheses to make the primitive accept more or fewer inputs
than are ordinarily required.
If the primitive name is preceded by a left parenthesis ["("], the primitive
processes as many inputs as it finds before the closing right parenthesis
[")"] without complaint. If no expression follows the parenthesized expression
on the line, you do not need to type the closing parenthesis.
angle brackets: < >
-------------------
Enclose optional inputs. (Inputs shown in angle brackets are not required.)
"or" bar: |
-----------
Separates alternative inputs. Enter one of the two inputs separated by |. For
example, name | name_list means you can enter either a name or a list of
names.
The following symbols represent the objects you can input to a primitive:
object
------
Means the primitive can accept any object as input: a word, a name, a number,
a list, or an expression that outputs a word, a name, a number, or a list. You
can also use a variable to represent any object input to a procedure.
name
----
Represents a special word that identifies either a procedure, a variable, or a
"package" of procedures and variables. When a primitive can accept only a
certain kind of name as input, one of the following symbols appears:
- varname a variable name
- procname a procedure name
- pkgname a package name
- d: a drive name
- fname a file name that can begin with an optional drive name to
specify a drive other than the default
- prop a property name; the first member of a property pair in a
property list
list
----
Means a list is required as input. A literal list is a series of Logo words,
numbers, or lists enclosed in square brackets ("[" and "]"). You can construct
a "not literal" list that contains the value of a variable by using the LIST
or SENTENCE primitive. Some of the special kinds of lists are:
- instr_list contains instructions to be executed
- coord_list contains a pair of numbers that define a location on the screen
- name_list contains names of variables, procedures, and/or packages
numbers: n, _n
--------------
Represent input numbers. N represents any number. You can enter an expression
that outputs a number anywhere N appears. _N is appended to a descriptive term
when a special number is required. For example, DEGREES_N means the input
number is interpreted as a number of degrees.
infix primitive inputs: a, b
----------------------------
Represent inputs to an infix primitive, where the primitive identifier is a
symbol embedded between the inputs. A and B can represent both numbers and
objects. In arithmetic expressions, A and B represent numbers, as in 1 + 2 and
12 / 6. In logical expressions, A and B can represent any object, as in [a b
c] = [a b c], 3 > 1, or :son = "greg.
pred_exp
--------
Represents a predicate expression, an expression that, when evaluated, outputs
either TRUE or FALSE.
Explanation
===========
Describes the action or result of an expression in detail. Discusses optional
inputs, punctuation, and how the primitive works with other primitives, if
appropriate.
In these discussions, "you" means you, the Dr. Logo programmer. "Your user"
refers to a person who runs your Dr. Logo procedure, and might type something
at the keyboard to interact with your procedure.
Examples
========
Shows expressions and procedures that demonstrate the capabilities of the
primitive. This section sometimes includes discussions of the example
expressions and procedures.
Most of the examples show you exactly what to type to get the response shown
in the text. However, some examples, such as those for erasing, must assume
there is already something in the workspace to erase. A brief description of
assumptions about the workspace precedes these examples. You might not be able
to reproduce these examples exactly, but, by studying them, you will learn the
capabilities of the primitives they demonstrate.
The examples assume that you are using a graphic screen, which has a line
length of 80 characters ("SETRES 1"). (For legacy reasons, Dr. Logo starts in
SETRES 0, providing 320x200 pixels. If you want a VGA screen (640x480), read
the explanations of the SETRES primitive.) When you have typed a 80-character
line, Dr. Logo enters an exclamation point ("!") which indicates that your
text continues on the next line. You do not type the exclamation point
yourself.
* (see product)
+ (see sum)
.contents (see contents)
.deposit (see deposit)
.examine (see examine)
.in (see in)
.out (see out)
.replace (see replace)
.reptail (see reptail)
.setseg (see setseg)
\ "Quoting character" = Ctrl-Q
There is a handful of commands which are not primitives. They can be
classified in 3 groups:
1) Non-standard I/O devices: PADDLE, BUTTONP, LPEN, LPENP
2) Enter/leave the editor/interpreter: TO, END, BYE
3) System variables: ERRACT, REDEFP
abs
---
Action:
Outputs the absolute value of the input number.
Syntax:
abs n
Explanation:
ABS outputs the absolute value of the input number. You can use ABS to show
the distance from the turtle's position to home excluding any + or - sign that
indicates its location in the coordinate scale. For example, if you move the
turtle back 50 steps from home, its position if [0 -50]. However, its distance
from home is the absolute value of -50 (sometimes shown as |-50|), or 50
turtle steps.
Examples:
?cs
?back 50
?pos
[0 -50]
?abs last pos
50
allopen
-------
Action:
Outputs a list of all data files currently open.
Syntax:
allopen
Explanation:
Outputs a list of all data files currently open.
(ROCHE> There is a system message, saying that "Only 4 files can be open".)
Examples:
?allopen
and
---
Action:
Outputs TRUE if all input predicate expressions output TRUE.
Syntax:
and pred_exp pred_exp (...)
Explanation:
AND outputs TRUE if all input predicate expressions output TRUE. Otherwise,
AND outputs FALSE.
Without punctuation, AND requires and accepts two input objects. AND can
accept more or fewer inputs when you enclose the AND expression in parentheses
["(" and ")"]. If no other expressions follow the AND expression on the line,
you do not need to type the closing right parenthesis [")"].
You can use an AND expression to test different conditions, or build your own
predicate procedure.
Examples:
?and "TRUE "TRUE
TRUE
?and "TRUE "FALSE
FALSE
?and "FALSE "FALSE
FALSE
?and (3<4) (7>3)
TRUE
?and (3=4) (7>3)
FALSE
?(and (3<4) (7>3) (9=9) (6<5))
FALSE
?to tub.right? :temperature
>if and (:temperature > 88) (:temperature < 102)
> [print [Just Right!]]
> [print [Not Right.]]
>end
tub.right? defined
?tub.right? 90
Just Right!
?to decimalp :object
>output and (numberp :object) (pointp :object)
>end
decimalp defined
?to pointp :object
>if emptyp :object
> [output "FALSE]
>if (first :object) = ".
> [output "TRUE]
>output pointp butfirst :object
>end
pointp defined
?decimalp 1995
FALSE
?decimalp 19.95
TRUE
?decimalp [nineteen.ninety-five]
FALSE
arctan
------
Action:
Outputs the arc tangent of the input number.
Syntax:
arctan n
Explanation:
ARCTAN outputs in degrees the angle whose tangent is the input number.
Examples:
?arctan 0
0
?arctan 1
45
?arctan 10
84.2894068625003
?arctan 100
89.4270613023165
?to plot.arctan
>make "val -pi
>make "inc pi / 37.5
>make "x -150
>setx 150
>setx :x
>plot.a :val
>end
plot.arctan defined
?to plot.a :val
>if :x > 150
> [stop]
>forward arctan :val
>sety 0
>setx :x + 4
>make "x :x + 4
>make "val :val + :inc
>plot.a :val
>end
plot.a defined
?plot.arctan
ascii
-----
Action:
Outputs the ASCII value of the first character in the input word.
Syntax:
ascii word
Explanation:
ASCII outputs an integer between 0 and 255 that is the American Standard
representation for the first character in the input word. The input word must
contain at least one character. The first character can be a letter, number,
or special character.
The American Standard Code for Information Interchange (ASCII) is a standard
code for representing numbers, letters, and symbols. The IBM Personal Computer
has many unique characters that are also represented by ASCII codes. The "Dr.
Logo Command Summary" contains a list of characters and their ASCII values.
Examples:
?ascii "g
103
?ascii "good
103
?ascii "2
50
?to encode :word
>if emptyp :word
> [output "]
>output word secret first :word encode butfirst :word
>end
encode defined
?to secret :character
>make "secret.code 5 + ascii :character
>if :secret.code > ascii "z
> [make "secret.code :secret.code - 26]
>output char :secret.code
>end
secret defined
?to decode :word
>if emptyp :word
> [output "]
>output word crack first :word decode butfirst :word
>end
decode defined
?to crack :character
>make "cracked.code (ascii :character= -5
>if :cracked.code < ascii "a
> [make "cracked.code :cracked.code + 26]
>output char :cracked.code
>end
crack defined
?make "password encode "plastics
?:password
uqfxynhx
?decode :password
plastics
back bk
-------
Action:
Moves the turtle the input number of steps in the opposite direction of its
heading.
Syntax:
back distance_n
bk distance_n
Explanation:
BACK moves the turtle the specified number of steps in the opposite direction
of its current heading. The turtle's heading and pen do not change. If the
turtle's pen is down, the turtle leaves a trace of its path. On the IBM
Personal Computer, a turtle step is equivalent to one dot (pixel).
BACK can help you write a procedure that leaves the turtle in the same
position when the procedure ends as it was when the procedure started. Leaving
the turtle in the same position makes it easy to call the procedure from
another procedure.
Examples:
?cs
?back 50
?cs
?to flag
>forward 50
>repeat 3
> [right 120 forward 25]
>back 50
>end
flag defined
?to wheel
>repeat 12
> [flag left 30]
>end
wheel defined
?flag
?wheel
bury
----
Action:
Hides the specified package from subsequent workspace management commands.
Syntax:
bury pkgname | pkgname_list
Explanation:
BURY hides the specified package or packages from workspace management
commands. BURY works by setting the bury property (.BUR) in the package's
property list to TRUE. The following primitives check property lists before
taking action, and ignore any buried procedures or variables:
edall erall glist pops save
edns erns poall pots
edps erps pons pps
All of these primitives optionally accept a package name as input. If no
package name is specified, these commands address the entire contents of the
workspace, except for buried packages. All other procedures access buried
procedures and variables normally. For example, a procedure that receives a
buried variable name as input accesses the buried variable normally. POTL and
POPKG display the names of buried procedures. PROCLIST includes all defined
procedure names, buried or unburied, in the list it outputs.
Examples:
These examples assume you have the following items in your workspace: two
packages named FIGURES and TITLES, two variables named BIG and SMALL, and four
procedures named PRAUTHOR, PRDATE, SQUARE, and TRIANGLE.
?popkg
figures
"big (VAL)
"small (VAL)
to square
to triangle
titles
to prauthor
to prdate
?bury "titles
?popkg
figures
"big (VAL)
"small (VAL)
to square
to triangle
titles is buried
to prauthor
to prdate
?pots
to square
to triangle
butfirst bf
-----------
Action:
Outputs all but the first element in the input object.
Syntax:
butfirst object
bf object
Explanation:
BUTFIRST outputs all but the first element of the input object. If the input
object is a list, BUTFIRST outputs a list containing every element of the
input list, except the first element. If the input object is a word, BUTFIRST
outputs a word containing all but the first character of the input word. If
the input object is an empty word or empty list, BUTFIRST returns an error.
Examples:
?butfirst "abalone
balone
?butfirst [semi sweet chocolate]
[sweet chocolate]
?butfirst [[chocolate chip] [walnut date] [oatmeal raisin]]
[[walnut date] [oatmeal raisin]]
?butfirst "y
?butfirst [brownie]
[]
?to vanish :object
>if emptyp :object
> [stop]
>print :object
>vanish butfirst :object
>end
vanish defined
?vanish "abracadabra
abracadabra
bracadabra
racadabra
acadabra
cadabra
adabra
dabra
abra
bra
ra
a
butlast bl
----------
Action:
Outputs all but the last element in the input object.
Syntax:
butlast object
bl object
Explanation:
BUTLAST outputs all but the last element of the input object. If the input
object is a list, BUTLAST outputs a list containing every element of the input
list, except the last element. If the input object is a word, BUTLAST outputs
a word containing all but the last character of the input word. If the input
object is an empty word or empty list, BUTLAST returns an error.
Examples:
?butlast "drawn
draw
?butlast [fudge walnut]
[fudge]
?butlast "y
?butlast [snickerdoodle]
[]
?to vanish :object
>if emptyp :object
> [stop]
>print :object
>vanish butlast :object
>end
vanish defined
?vanish "turkey
turkey
turke
turk
tur
tu
t
buttonp (= BUTTON Predicate) (Not a primitive)
-------
Action:
Outputs TRUE if the button on the specified paddle (joystick) is down.
Syntax:
buttonp paddle_n
Explanation:
BUTTONP outputs TRUE if the button on the specified paddle or joystick is
down. Dr. Logo can accept input from two paddle. Each paddle can have two
buttons. You use BUTTONP to determine whether or not a button in pressed. If
you do not have a paddle or joystick, BUTTONP always output FALSE.
BUTTONP requires an input number to identify one of the four paddle buttons.
Numbers in the range 0 to 3 identify the paddle buttons as follows:
0 identifies button 1, paddle 1
1 identifies button 2, paddle 1
2 identifies button 1, paddle 2
3 identifies button 2, paddle 2
Examples:
DRAW allows the user to guide the turtle with the joystick. The two BUTTONP
commands allow the user to stop drawing or erase the drawing by pressing the
paddle buttons. DRAW is more fully described under PADDLE.
?to draw
>repeat 10000
> [make "xin paddle 0
> make "yin paddle 1
> make "xin int ((:xin * (300 / 190)) - 150)
> make "yin int ((:yin * (-200 / 144)) + 90)
> setheading towards list :xin :yin
> forward [amount * 0.1]
> if buttonp 0 [stop]
> if buttonp 1 [clean]
>end
draw defined
?to amount
>output int sqrt
> ((abs :xin) * (abs :xin) +
> ((abs :yin) * (abs :yin)))
>end
amount defined
?draw
bye (Not a primitive)
---
Action:
Exits Dr. Logo and returns to the operating system.
Syntax:
bye
Explanation:
Exits current session of Dr. Logo and returns to the operating system. You can
enter BYE to Dr. Logo's ? or ! prompt; BYE is not valid when you are in the
editor or while you are executing a procedure. When you enter BYE, any
procedures or variables you have not saved on disk are lost.
Examples:
?bye
catch
-----
Action:
Traps errors and special conditions that occur during the execution of the
input instruction list.
Syntax:
catch name instr_list
Explanation:
CATCH works with the THROW primitive to let your procedure handle special
conditions. For example, by using CATCH and THROW, your procedure can display
a special message if your user types something incorrectly. CATCH and THROW
can also intercept an error that would normally make Dr. Logo display a
message on the screen.
CATCH and THROW each require a name as input. To pair a CATCH expression with
a THROW expression, you must give the CATCH and THROW expressions the same
input name.
When a CATCH command is executed, Dr. Logo simply executes the input
instruction list. Execution proceeds normally until a THROW expression,
usually in a called procedure, identifies a special condition. Then, Dr. Logo
returns to the procedure that contains the CATCH command identified by the
THROWn name. Dr. Logo then executes the line that follows the CATCH command.
There are two special names you can input to catch: TRUE and ERROR. TRUE
matches any THROW name, so CATCH "TRUE catches any THROW. Dr. Logo
automatically executes a THROW "ERROR command when an error occurs. Therefore,
a CATCH "ERROR expression catches any error that occurs. Without CATCH "ERROR,
an error makes Dr. Logo print a message on the screen, terminate your
procedure's execution, and return to toplevel (the ? prompt). The description
of the ERROR primitive tells how to find out what the error was.
Examples:
The COIL procedure asks the user to enter increasingly larger numbers as the
turtle draws a coil on the screen. If the user types a number that is not
bigger than the last one entered, COIL reminds the user what to type and
continues working.
?to coil
>print [Enter a small number.]
>make "previous 0
>forward grow.number
>right 30
>trap
>end
coil defined
?to grow.number
>make "growth first readlist
>if :growth < :previous
> [throw "not.bigger]
>make "previous :growth
>output :growth
>end
grow.number defined
?to trap
>catch "not.bigger [draw.coil]
>(print [Enter a number bigger than] :previous)
>trap
>end
trap defined
?to draw.coil
>print [Enter a bigger number.]
>forward grow.number
>right 30
>draw.coil
>end
draw.coil defined
?coil
The THROW "NOTBIGGER instruction in the GROW.NUMBER procedure always returns
Dr. Logo to the TRAP procedure. If a STOP instruction had been used instead of
THROW, Dr. Logo would return to the procedure that called GROW.NUMBER, which
might be either COIL or DRAWCOIL.
The following procedures allow the user to type commands just as if typing to
the Dr. Logo interpreter. However, if the user enters a command incorrectly,
the MY.MESSAGE procedure traps the normal Dr. Logo error message, and prints a
custom message.
?to my.message
>catch "error [interpret]
>(print "Oops! first butfirst error [!!!])
>print [What do you want to do about that?]
>run readlist
>my.message
>end
my.message defined
?to interpret
>print [What next, boss?]
>run readlist
>interpret
>end
interpret defined
?interpret
Hello!
changef (= CHANGE Filename)
-------
Action:
Changes the name of a file in the disk directory.
Syntax:
changef < d: > new_fname old_fname
Explanation:
CHANGEF changes the name of a file in a disk directory. Enter the name you
want to give the file, followed by the file's current name. You can put a disk
specifier in front of the old name if the file is not on the default disk
drive.
Examples:
The following examples assume you have three Dr. Logo files on the disk in the
default drive: PIGLATIN, FLY, and SHAPES.
?dir
[PIGLATIN.LOG FLY.LOG SHAPES.LOG]
?changef "pigl "piglatin
?dir
[PIGL.LOG FLY.LOG SHAPES.LOG]
(ROCHE> I found the following procedure useful...)
to ren :new_fname :old_fname
changef :new_fname :old_fname
end
char
----
Action:
Outputs the character whose ASCII value is the input number.
Syntax:
char n
Explanation:
CHAR outputs the character whose ASCII value is the input number. CHAR
requires an integer between 0 and 255 as input.
The American Standard Code for Information Interchange (ASCII) is a standard
code for representing numbers, letters, and symbols. The IBM Personal Computer
has many unique characters that are also represented by ASCII codes. The "Dr.
Logo Command Summary" contains a list of characters and their ASCII codes.
Examples:
?char 103
g
?char 50
2
?repeat 20 [(type random 10 char 9)]
3 0 6 1 3 5 1 8 0 1 8 6 7 1 1 9 3 8 4 5
?to encode :word
>if emptyp :word
> [output "]
>output word secret first :word encode butfirst :word
>end
encode defined
?to secret :character
>make "secret.code (ascii :character) + 5
>if :secret.code > (ascii "z)
> [make "secret.code :secret.code - 26]
>output char :secret.code
>end
secret defined
?to decode :word
>if emptyp :word
> [output "]
>output word crack first :word decode butfirst :word
>end
decode defined
?to crack :character
>make "cracked.code (ascii :character) - 5
>if :cracked.code < (ascii "a)
> [make "cracked.code :cracked.code + 26]
>output char :cracked.code
>end
crack defined
?make "password encode "elephant
?:password
jqjumfsy
?decode :password
elephant
clean
-----
Action:
Erases the graphic screen without affecting the turtle.
Syntax:
clean
Explanation:
CLEAN erases everything the turtle has drawn on the graphic screen, but leaves
the turtle in its current heading and location.
Examples:
?to tri.spi :side
>if :side > 80
> [stop]
>forward :side right 120
>tri.spi (:side + 3)
>end
tri.spi defined
?tri.spi 5
?clean
clearscreen cs
--------------
Action:
Erases the graphics screen and puts the turtle in the home position.
Syntax:
clearscreen
cs
Explanation:
CLEARSCREEN erases everything the turtle has drawn on the graphic screen, and
returns the turtle "home" to location [0 0] heading 0 (North).
Examples:
?to tri.spi :side
>if :side > 80
> [stop]
>forward :side right 120
>tri.spi (:side + 3)
>end
tri.spi defined
?tri.spi 5
?clearscreen
cleartext ct
------------
Action:
Erases all text in the window that currently contains the cursor, then
positions the cursor in the upper left corner of the window.
Syntax:
cleartext
ct
Explanation:
CLEARTEXT erases all text displayed in the window currently containing the
cursor, then positions the cursor at the upper left corner of the window. For
example, if your entire screen is devoted to text, CLEARTEXT erases the entire
screen, and places the cursor in the upper left corner.
Examples:
This example assumes you have the following items in your worskpace: two
packages named FIGURES and TITLES, two variables named BIG and SMALL, and four
procedures named PRAUTHOR, PRDATE, SQUARE, and TRIANGLE.
?popkg
figures
"big (VAL)
"small (VAL)
to square
to triangle
titles
to prauthor
to prdate
?cleartext
close
-----
Action:
Closes the named data file.
Syntax:
close fname
Explanation:
Closes the named data file.
Examples:
?close "Ketchum
closeall
--------
Action:
Closes all the data files currently open.
Syntax:
closeall
Explanation:
Closes all the data files currently open.
(ROCHE> There is a system message, saying that "Only 4 files can be open".)
Examples:
?closeall
co
--
Action:
Ends a pause that is caused by a PAUSE expression or a Ctrl-Z keystroke.
Syntax:
co
Explanation:
CO continues the execution of a procedure interrupted by a PAUSE. During a
pause, you can interact with the interpreter to debug your procedure. Enter CO
when you have finished with the interpreter and want to continue the execution
of the procedure.
There are three ways to cause a pause during the execution of a procedure:
1) the execution of a PAUSE expression within the procedure
2) a Ctrl-Z keystroke
3) any error, if the system variable ERRACT is TRUE.
When a PAUSE interrupts the execution of a procedure, Dr. Logo displays a
"Pausing..." message and shows the name of the interrupted procedure before
the interpreter's ? prompt. No matter which way you begin a pause, you must
use CO to end it and continue your procedure's execution.
Examples:
?to box.spi :side
>if and (:side > 80) (:side < 90)
> [pause]
>forward :side right 90
>box.spi (:side + 5)
>end
box.spi defined
?box.spi 5
Ctrl-Z
Pausing... in box.spi: fd
box.spi ?:side
60
box.spi ?co
Pausing... in box.spi: [if and :side > 80 :side < 90 [pause]]
box.spi ?:side
85
box.spi ?co
.contents
---------
Action:
Displays the contents of the Dr. Logo symbol space.
Syntax:
.contents
Explanation:
Displays the contents of the Dr. Logo symbol space.
Examples:
?sort .contents
[() * + - .APV .BUR .DEF .ENL .FIL .FMT .PAK .PKG .PRM .RDR .REM .SPC .WTR
.contents .deposit .examine .in .out .replace .reptail .setseg / < <= <> = =<
=> > >< >= FALSE TRUE ^ abs allopen an empty word and arctan ascii back bf bk
bl bury butfirst butlast catch changef char clean clearscreen cleartext close
closeall co copydef copyoff copyon cos count cs ct cursor defaultd define
definedp degrees dir dirpic dot dotc ed edall edf edit edns edps eform emptyp
equalp er erall erase erasefile erasepic ern erns erps erract error exp fd
fence fill first follow form forward fput fs fullscreen glist go gprop heading
help hideturtle home ht if iff iffalse ift iftrue int item keyp label last lc
left list listp load loadpic local log log10 lowercase lput lt make memberp
mouse name namep nodes noformat not notrace nowatch numberp op open or output
package pal pause pd pe pendown penerase penreverse penup pi piece pkgall
plist po poall pocall pons popkg pops poref pos potl pots pprop pps pr prec
primitivep print proclist product pu px quotient radians random rc readchar
readeofp reader readlist readquote recycle redefp remainder remprop repeat
rerandom right rl round rq rt run save savepic screenfacts se sentence setbg
setcursor setd seth setheading setpal setpan setpc setpen setpos setprec
setread setres setscrunch setsplit setwrite setx sety setzoom sf show
showturtle shuffle sin sort splitscreen sqrt ss st stop sum tan test text
textscreen tf thing throw tones toplevel towards trace ts tt turtlefacts
turtletext type uc unbury uppercase wait watch where window word wordp wrap
writer xcor ycor]
(ROCHE>
.APV = Associated Property Value
.BUR = BURied
.CAT = CATch
.DEF = DEFinition of a procedure
.ENL = ENd of Line
.FIL = FILe specification
.FMT = ForMaT (indentation)
.PAK = PAcKaged procedure
.PKG = PacKaGe name
.PRM = PRiMitive
.RDR = ReaDeR
.REM = REMark (;)
.SPC = SPaCe
.WTR = WriTeR
)
copydef
-------
Action:
Makes a copy of a procedure definition, and gives it a new name.
Syntax:
copydef new_procname old_procname
Explanation:
COPYDEF makes a copy of a procedure definition, and gives it a new name.
COPYDEF creates a new procedure by making an exact copy of an existing
procedure definition, and giving it a new title line. The new procedure
becomes a part of your workspace, and can be referenced, edited, and saved on
disk.
You cannot associate a second name with a Dr. Logo primitive, unless you have
made the system variable REDEFP TRUE. If the old_procname is a primitive, the
new_procname takes all the characteristics of a primitive; it cannot be
printed out or edited.
Examples:
?to box :side
>repeat 4
> [forward :side right 90]
>end
box defined
?copydef "square "box
?po "square
to square :side
repeat 4 [forward :side right 90]
end
copyoff
-------
Action:
Stops echoing text at the printer.
Syntax:
copyoff
Explanation:
COPYOFF stops the echoing of text at the printer. If you have a printer, you
can start printer echo with COPYON.
Examples:
These examples assume you have three files named PIGL, FLY, and SHAPES on the
disk in the default drive.
?copyon
?dir \
[PIGL.LOG FLY.LOG SHAPES.LOG] > This is echoed on the printer.
?copyoff /
?dir
[PIGL.LOG FLY.LOG SHAPES.LOG]
copyon
------
Action:
Starts echoing text at the printer.
Syntax:
copyon
Explanation:
COPYON starts echoing text at the printer, if you have one. After COPYON,
everything Dr. Logo displays on your text screen is also printed at the
printer. You can stop printer echo with COPYOFF.
Examples:
The following exampes assume you have three files named PIGL, FLY, and SHAPES
on the disk in the default drive.
?copyon
?dir \
[PIGL.LOG FLY.LOG SHAPES.LOG] > This is echoed on the printer.
?copyoff /
?dir
[PIGL.LOG FLY.LOG SHAPES.LOG]
cos
---
Action:
Outputs the cosine of the input number of degrees.
Syntax:
cos degrees_n
Explanation:
COS outputs the trigonometric cosine of the input number of degrees. COS
outputs a decimal number between 0 and 1.
Examples:
?cos 0
1
?to plot.cosine
>setpc 2
>make "val 0
>make "x -150
>make "inc (300 / 60)
>setx 150 setx -150
>penup setpos list :x 90 pd
>setpc 1
>plot.c :val
>end
plot.cosine defined
?to plot.c :val
>if :x > 150
> [stop]
>make "y (90 * (cos :val)) ; 90 makes plot visible
>setheading towards list :x :y
>setpos list :x :y
>make "x :x + :inc
>make "val :val + 6
>plot.c :val
>end
plot.c defined
?plot.cosine
count
-----
Action:
Outputs the number of elements in the input object.
Syntax:
count object
Explanation:
COUNT outputs the number of elements in the input object, which can be a word,
number, or list. To count the items in a list within a list, use an ITEM
expression as input to COUNT.
Examples:
?count "chocolate
9
?count [chocolate]
1
?count [vanilla strawberry [mocha unsweetened milk german]]
3
?count item 3 [vanilla strawberry [mocha unsweetened milk german]]
4
cursor
------
Action:
Outputs a list that contains the column and line numbers of the cursor's
position within the text window.
Syntax:
cursor
Explanation:
CURSOR outputs a coordinate list that contains the column and line numbers of
the cursor's position within the text window. The first element of the list is
the column number; the second, the line number. The line number ranges from 0
to 24. The column number ranges from 0 to 79.
Examples:
?cleartext
?cursor
[0 1]
?(type [The current cursor position is\ ] show cursor
The current cursor position is [32 23]
?print sentence [The current cursor position is:] cursor
The current cursor position is: 0 24
defaultd (= DEFAULT Drive name)
--------
Action:
Outputs the name of the current default drive.
Syntax:
defaultd
Explanation:
DEFAULTD outputs the name of the current default drive. Dr. Logo looks in the
directory of the disk in the default drive when you do not specify a drive
name in a disk command such as SAVE, LOAD, ERASEFILE, CHANGEF, or DIR.
Examples:
?to saved
>make "disk.name defaultd
>end
saved defined
?to restored
>setd :disk.name
>end
restored defined
?defaultd
A:
?saved
?setd b:
?defaultd
B:
?restored
?defaultd
A:
define
------
Action:
Makes the input definition list the definition of the specified procedure
name.
Syntax:
define procname defin_list
Explanation:
DEFINE allows you to write a procedure that can, in turn, define other
procedures. A DEFINE expression defines a procedure without using an editor
(such as EDIT or ED), TO, or END.
DEFINE requires two inputs: a name and a definition list. Note that the name
you input to DEFINE cannot be the name of a Dr. Logo primitive, unless REDEFP
is TRUE.
A definition list is a special kind of list with a special format. The first
element of the input list must be a list of names for inputs to the procedure.
Do not put colons (":") before names in this list! If the procedure is to
require no inputs, the first element in DEFINE's input list must be an empty
list. DEFINE uses the input name and the first element of the definition list
to compose the title line of the procedure.
Each remaining element of DEFINE's input list must be a list containing one
line of the procedure definition. Do not put END in this list; END is not a
part of a procedure's definition.
The TEXT primitive also uses this format when it outputs a definition list. In
fact, you can use a TEXT expression to input a definition list to DEFINE.
Examples:
?define "say.hello [[] [print [Hello world!]]
?po "say.hello
to say.hello
print [Hello world!]
end
?to learn
>make "definition [[]]
>print [Enter expressions you would like saved in a procedure.]
>print [Enter ERASE to delete your last instruction.]
>read.lines
>print [Type Y to define procedure, any other key to abandon.]
>test lowercase readchar = "y
>iftrue [type [Name for procedure?]
> make "title first readlist
> define :title :definition]
>end
learn defined
?to read.lines
>make "newline readlist
>if lowercase :newline = [end]
> [stop]
>if lowercase :newline = [erase]
> [delete]
> [run :newline make "definition lput :newline :definition]
>read.lines
>end
read.lines defined
?to delete
>print sentence "Deleting last :definition
>make "definition butlast :definition
>end
delete defined
?learn
Enter expressions you would like saved in a procedure.
Enter erase to delete your last instruction.
cs
erase
Deleting cs
setpc 1
forward 40 right 90
setpc 2
repeat 36 [forward 5 left 10]
left 90 setpc 1 back 40
print "balloon!
balloon!
end
Type Y to define procedure, any other key to abandon. y
Name for procedure?
balloon
?balloon
balloon!
definedp (= DEFINED Predicate)
--------
Action:
Outputs TRUE if the input name identifies a defined procedure.
Syntax:
definedp object
Explanation:
DEFINEDP outputs TRUE if the input name identifies a procedure currently
defined in the workspace. DEFINEDP returns FALSE if the input name identifies
a primitive name, a variable name, or anything but a defined procedure name.
Examples:
?to balloon
>setpc 1
>forward 40 right 90
>setpc 2
>repeat 36
> [forward 5 left 10]
>left 90 setpc 1 back 40
>print "balloon!
>end
balloon defined
?definedp "balloon
TRUE
?definedp "definedp
FALSE
degrees
-------
Action:
Outputs the number of degrees in the input number of radians.
Syntax:
degrees radian_n
Explanation:
DEGREES outputs the number of degrees in the input number of radians, where
degrees = radians * (180 / pi).
Examples:
?degrees 1
57.2957795130823
?degrees 2
114.591559026165
?degrees 3
171.887338539247
?to degrees.cycle :vals
>if emptyp :vals
> [stop]
>(print [There are] degrees (run first :vals) [degrees in] first :vals
"radians.)
>make "vals butfirst :vals
>degrees.cycle :vals
>end
degrees.cycle defined
?make "vals [[pi] [(pi / 2)] [(pi /4)] [(pi / 8)]]
?degrees.cycle :vals
There are 180 degrees in pi radians.
There are 90 degrees in (pi / 2) radians.
There are 45 degrees in (pi / 4) radians.
There are 22.5 degrees in (pi / 8) radians.
.deposit
--------
Action:
Puts a number into a memory location.
Syntax:
.deposit n n
Explanation:
Puts the second input number into the memory location specified by the first
input number. This location is relative to the absolute location established
by .SETSEG. THIS PRIMITIVE SHOULD BE USED WITH CAUTION!
Examples:
?.deposit 2 3
dir
---
Action:
Outputs a list of the Dr. Logo file names on the default or specified disk.
Syntax:
dir < d: >
Explanation:
DIR outputs a list of Dr. Logo file names on the default or specified disk. If
you do not specify a disk drive, DIR looks in the directory of the default
disk.
DIR accepts an ambiguous file name as input. An ambiguous file name can refer
to more than one file because it contains a wildcard character and gives Dr.
Logo a pattern to match. Dr. Logo can then display the file names that match
the pattern.
The wildcard character is a question mark ("?"). When the last character in
your input file name is a question mark, DIR displays the file names that
begin with the characters that precede the question mark. (ROCHE> There seems
to be a bug in the version available, as ? does not work. To get ambiguous
file names, fill the name (and/or typ) field(s) with ?. Example: DIR
F???????.T??)
The list DIR outputs contains the names of only those files that are
identified by the LOG file type in the disk's directory. SAVE automatically
gives the file type LOG to the files it stores on disk.
Examples:
These examples assume you have three files named SHAPES, PLAID, and PIGLATIN
on the disk in the default drive, and two files named COIL and FLY on the disk
in drive B.
?dir
[SHAPES.LOG PLAID.LOG PIGLATIN.LOG]
?dir "b:
[COIL.LOG FLY.LOG]
?dir "p???????
[PLAID.LOG PIGLATIN.LOG]
dirpic
------
Action:
Outputs a list of the Dr. Logo picture files on the default or specified disk.
Syntax:
dirpic < d: >
Explanation:
DIRPIC outputs a list of Dr. Logo picture files on the default or specified
disk. If you do not specify a disk drive, DIRPIC looks in the directory of the
default disk.
DIRPIC accepts an ambiguous picture filename as input. An ambiguous picture
filename can refer to more than one picture file because it contains a
wildcard character and gives Dr. Logo a pattern to match. Dr. Logo can then
display the picture filenames that match the pattern.
The wildcard character is a question mark ("?"). When the last character in
your input picture filename is a question mark, DIRPIC displays the picture
filenames that begin with the characters that precede the question mark.
(ROCHE> There seems to be a bug in the version available, as ? does not work.
To get ambiguous file names, fill the name (and/or typ) field(s) with ?.
Example: DIR F???????.T??)
The list DIRPIC outputs contains the names of only those picture files that
are identified by the PC0 file type in the disk's directory. SAVEPIC
automatically gives the picture filetype PC0 to the files it stores on disk.
(ROCHE> for SETRES 0 images. But images saved under SETRES 1 are given the PC1
file type... and DIRPIC is then unable to find them! This is clearly a bug.
The solution is to use an ambiguous filespec, with .PC? for the file type.)
Examples:
These examples assume you have three picture files named SHAPES, PLAID, and
PIGLATIN on the disk in the default drive.
?dirpic
[SHAPES.PC0 PLAID.PC0 PIGLATIN.PC0]
?dirpic "p???????.pc?
[PLAID.PC0 PIGLATIN.PC0 PLAID.PC1 PIGLATIN.PC1]
dot
---
Action:
Plots a dot at the position specified by the input coordinate list.
Syntax:
dot coord_list
Explanation:
DOT plots a dot at the position specified by the input graphic screen
coordinate list. The turtle is not affected in any way.
Examples:
?dot [50 50]
?to snow
>make "x random 150 * (first shuffle [1 -1])
>make "y random 100 * (first shuffle [1 -1])
>dot list :x :y
>snow
>end
snow defined
?snow
dotc (= DOT Color)
----
Action:
Outputs the color number of a given dot.
Syntax:
dotc coord_list
Explanation:
Outputs the color number of the dot at the coordinates specified, or -1 if the
location is not on the graphic viewport.
Examples:
?dotc [50 10]
2
edall (= EDit ALL)
-----
Action:
Loads all the variables and procedures in the workspace or specified
package(s) into the screen editor's buffer, and enters the screen editor.
Syntax:
edall < pkgname | pkgname_list >
Explanation:
With or without an input, EDALL loads variables and procedures into the screen
editor's buffer, and enters the screen editor. EDALL without an input loads
all procedures and variables from Dr. Logo's workspace into the screen
editor's buffer. If there is nothing in the workspace, the screen editor
displays an empty buffer into which you can type either procedures or
variables.
You can input a package name or a list of package names to specify a group of
procedures and variables to edit. EDALL accepts only defined package names as
input.
Within the screen editor, you can use line editing and screen editing control
character commands to move the cursor, make changes to text, and exit the
screen editor. The control character commands are described in Section 3,
"Editing Commands", and summarized in Appendix B, "Dr. Logo control and escape
character commands".
Examples:
These examples assume you have two packages named DRAW.PACK and MOVE.PACK in
your workspace.
?edall
EDALL loads all the variables and procedures in Dr. Logo's workspace into the
screen editor's buffer.
?edall "draw.pack
EDALL loads all the variables and procedures in the package DRAW.PACK into the
screen editor's buffer.
?edall [draw.pack move.pack]
EDALL loads all the variables and procedures in the packages DRAW.PACK and
MOVE.PACK into the screen editor's buffer.
edf (= EDit File)
---
Action:
Loads a disk file into the text editor.
Syntax:
edf fname
Explanation:
EDF takes a file name as input. It can load the specified disk file directly
into the screen editor's buffer, or create a new disk file with the specified
name and enter the screen editor with an empty buffer.
When you start the screen editor using EDF, Dr. Logo updates the disk rather
than the workspace when you press Ctrl-C to exit the screen editor. If you
press Ctrl-G, Dr. Logo stops and does not update the disk.
One of the advantages of saving information directly from the screen editor's
buffer to disk is that you can store individual command lines or expressions
in the disk file. When you end a workspace edit with Ctrl-C, Dr. Logo updates
only the definitions of procedures and variables in the workspace. Any stand-
alone expressions within the edit buffer are lost. However, when Dr. Logo
updates the disk, it saves stand-alone expressions. When you LOAD a file that
contains stand-alone expressions, Dr. Logo executes them in the same sequence
it reads them from disk. Use EDF to create a STARTUP file that automatically
executes the procedures it contains.
(ROCHE> When you type Ctrl-C, Dr. Logo saves the file on the disk. If you type
Ctrl-G, it is erased from memory. Note that EDF is a full-screen file editor,
and can edit files up to 4KB. It does not word-warp but, if you need word-
wrap, then you should use a real word-processor, in which case WordStar is, of
course, the standard under CP/M.)
Examples:
?edf "startup
edit ed
-------
Action:
Loads the specified procedure(s) and/or variable(s) into the screen editor's
buffer, and enters the screen editor.
Syntax:
edit < name | name_list >
ed < name | name_list >
Explanation:
An EDIT command enters the screen editor. EDIT can load procedures, variables,
or both into the screen editor's buffer. Input a procedure or variable name,
or a list of procedure and variable names to specify what you want to edit.
EDIT is "smart" and assumes certain things about your objectives for an
editing session. First, it knows that you frequently use the screen editor to
correct errors in procedures. So, when the execution of a procedure ends with
an error message and you immediately enter an edit command without specifying
a procedure name, EDIT automatically loads the erroneous procedure into the
screen editor, and positions the cursor at the line in which the error
occurred.
If no error has occurred, EDIT without an input procedure name displays an
empty screen editor buffer. When you start to edit an empty buffer, the
display is completely blank. You can type variable and procedure definitions
into the empty buffer.
EDIT's second assumption is that, when you are defining a new procedure, you
need title and ending lines. When you input an undefined procedure name in an
edit command, EDIT creates title and ending lines in the screen editor's
buffer.
Within the screen editor, you can use line editing and screen editing control
character commands to move the cursor, make changes to text, and exit the
screen editor. The control character commands are described in Section 3,
"Editing Commands", and summarized in Appendix B, "Dr. Logo control and escape
character commands".
Examples:
The following examples assume that you have the following in your workspace: a
variable named PASSWORD and four procedures named SQUARE, VANISH, ENCODE, and
SECRET.
I don't know how to repaet in square: repeat 4 [forward 25 left 90]
?ed
EDIT automatically loads SQUARE into the screen editor's buffer and positions
the cursor at the misspelling "repaet".
?edit "vanish
EDIT loads the procedure VANISH into the screen editor's buffer, and positions
the cursor at the end of the title line.
?ed [encode secret password
ED loads the ENCODE and SECRET procedures and the variable PASSWORD into the
screen editor's buffer, and positions the cursor after ENCODE's title line.
?ed "new.idea
ED with an undefined procedure name automatically creates title and end lines
in the screen editor's buffer.
edns (= EDit NameS)
----
Action:
Loads all the variables in the workspace or specified package(s) into the
screen editor's buffer, and enters the screen editor.
Syntax:
edns < pkgname | pkgname_list >
Explanation:
With or without an input, EDNS loads variables into the screen editor's
buffer, and enters the screen editor. EDNS without an input loads all
variables from Dr. Logo's workspace into the screen editor's buffer. If there
is nothing in the workspace, the screen editor displays an empty buffer into
which you can type variable and procedure definitions.
You can input a package name or a list of package names to specify a group of
variables to edit. EDNS accepts only defined package names as input.
Within the screen editor, you can use line editing and screen editing control
character commands to move the cursor, make changes to text, and exit the
screen editor. The control character commands are described in Section 3,
"Editing Commands", and summarized in Appendix B, "Dr. Logo control and escape
character commands".
Examples:
The following examples assume that you have two packages named DRAW.PACK and
MOVE.PACK in your workspace.
?edns
EDNS loads all the variables in Dr. Logo's workspace into the screen editor's
buffer.
?edns "draw.pack
EDNS loads all the variables in the package DRAW.PACK into the screen editor's
buffer.
?edns [draw.pack move.pack]
EDNS loads all the variables in the packages DRAW.PACK and MOVE.PACK into the
screen editor's buffer.
edps (= EDit ProcedureS)
----
Action:
Loads all the procedures in the workspace or specified package(s) into the
screen editor's buffer, and enters the screen editor.
Syntax:
edps < pkgname | pkgname_list >
Explanation:
With or without an input, EDPS loads procedures into the screen editor's
buffer, and enters the screen editor. EDPS without an input loads all
procedures from Dr. Logo's workspace into the screen editor's buffer. If there
is nothing in the workspace, the screen editor displays an empty buffer into
which you can type either procedures or variables.
You can input a package name or a list of package names to specify a group of
procedures to edit. EDPS accepts only defined package names as input.
Within the screen editor, you can use line editing and screen editing control
character commands to move the cursor, make changes to text, and exit the
screen editor. The control character commands are described in Section 3,
"Editing Commands", and summarized in Appendix B, "Dr. Logo control and escape
character commands".
Examples:
The following examples assume that you have two packages named DRAW.PACK and
MOVE.PACK in your workspace.
?edps
EDPS loads all the procedures in Dr. Logo's workspace into the screen editor's
buffer.
?edps "draw.pack
EDPS loads all the procedures in the package DRAW.PACK into the screen
editor's buffer.
?edps [draw.pack move.pack]
EDPS loads all the procedures in the packages DRAW.PACK and MOVE.PACK into the
screen editor's buffer.
eform (= Exponential FORMat)
-----
Action:
Outputs a number in scientific notation.
Syntax:
eform n1 n2
Explanation:
Outputs N1 in scientific notation, using N2 digits. N2 must be a positive,
real number from 1 through 15.
Examples:
?eform 1.2 1
1.E+00
emptyp (= EMPTY Predicate)
------
Action:
Outputs TRUE if the input object is an empty word or an empty list.
Syntax:
emptyp object
Explanation:
An EMPTYP expression returns TRUE only if the input object is an empty word or
empty list. Use EMPTYP as the predicate expression in an IF command to
determine if all elements of an object input to the procedure have been
processed.
Examples:
?to nest.circles :sizes
>if emptyp :sizes
> [stop]
>repeat 36
> [forward first :sizes left 10]
>nest.circles butfirst :sizes
>end
nest.circles defined
?make "sizes [1 2 3 4 5 6 7 8]
?nest.circles :sizes
end (Not a primitive)
---
Action:
Indicates the end of a procedure definition.
Syntax:
end
Explanation:
END is a special word that signals the end of a procedure definition. When you
are using TO to define a procedure, you must put END by itself as the last
line of the procedure.
END signals to the procedure editor (the > prompt) that you have finished
defining a procedure, and returns you to the interpreter's ? prompt. The
screen editor automatically inserts END, if you press Ctrl-C and exit without
entering END. Dr. Logo also adds an END line to a procedure defined with a
DEFINE expression.
END is not part of a procedure's definition list, and is not a primitive. You
can use END as a procedure or variable name, if you are confident that the
name will not cause undue confusion.
Examples:
?to pent
>repeat 5
> [forward 25 left 72]
>end
pent defined
END signals the procedure editor that you have finished defining a procedure,
and returns you to the interpreter's ? prompt.
?define "pent [[] [repeat 5 [forward 25 left 72]
?po "pent
to pent
repeat 5 [forward 25 left 72]
end
The DEFINE expression automatically adds an END line to the procedure
definition.
equalp (= EQUAL Predicate)
------
Action:
Outputs TRUE if the input objects are equal numbers, identical words, or
identical lists.
Syntax:
equalp object object
Explanation:
EQUALP outputs TRUE only if the input objects are equal numbers, identical
words, or identical lists; otherwise, EQUALP outputs FALSE.
Examples:
?equalp " []
FALSE
?equalp "leaf first [leaf stem flower]
TRUE
?equalp 72 (360 / 5)
TRUE
?equalp [1 2 3] [2 3 4]
FALSE
erall (= ERase ALL)
-----
Action:
Erases all the procedures and variables from the workspace or specified
package(s).
Syntax:
erall < pkgname | pkgname_list >
Explanation:
ERALL erases the definitions of procedures and variables. ERALL without an
input name erases the definitions of all procedures and variables from Dr.
Logo's workspace, except for any procedures and variables in buried packages.
ERALL without an input name also erases the package names of any unburied
packages.
You can give ERALL a package name or a list of package names to specify a
group of procedures and variables to be erased. ERALL can accept a buried
package name as input; with this request, ERALL can erase a buried package.
ERALL works by removing property pairs from the property lists associated with
package, variable, and procedure names. It removes the .PKG pair from a
package's property list, the .APV and .PAK pairs from a variable's property
lists, and the .DEF and .PAK pairs from a procedure's property list. ERALL
does not remove any other property pairs from a property list. So, after you
input a buried package name to ERALL, GLIST ".BUR still outputs the name of
the erased package. To completely remove the name from your workspace, you
must use a REMPROP command to eliminate all pairs from its property list.
Examples:
These examples assume you have two packages named DRAW.PACK and MOVE.PACK in
your workspace.
?erall
This command erases the definitions of all unburied procedures, variables, and
packages from Dr. Logo's workspace.
?erall "draw.pack
This command erases the definitions of procedures and variables in the
DRAW.PACK package, as well as the definition of DRAW.PACK as a package name.
?erall [draw.pack move.pack]
This command erases the definitions of the procedures, variables, and package
names associated with DRAW.PACK and MOVE.PACK.
erase er
--------
Action:
Erases the specified procedure(s) from the workspace.
Syntax:
erase procname | procname_list
er procname | procname_list
Explanation:
ERASE erases the specified procedure or procedures from Dr. Logo's workspace.
ERASE works by removing the .DEF pair from a procedure's property list. If a
procedure has other property pairs in its list besides .DEF, you must remove
them with REMPROP to completely erase the procedure name from the workspace.
Examples:
Each of these examples assume you have two procedures named WHEEL and FLAG in
a package named MANDALA in your workspace.
?erase "wheel
This command erases the definition of the WHEEL procedure from Dr. Logo's
workspace.
?erase [wheel flag]
This command erases the definitions of the procedures WHEEL and FLAG from Dr.
Logo's workspace.
?plist "wheel
[.PAK mandala [[] [repeat 12 [flag left 30]]]]
?erase "wheel
?plist "wheel
[.PAK mandala]
ERASE removes only the definition (.DEF) pair from a procedure name's property
list. Use REMPROP to delete .PAK.
erasefile
---------
Action:
Erases the specified Dr. Logo file.
Syntax:
erasefile fname
Explanation:
ERASEFILE erases a file name from a disk directory. You can enter a drive name
before the file name, to erase a file not on the default drive.
ERASEFILE accepts an ambiguous file name as input. An ambiguous file name can
refer to more than one file because it contains a wildcard character and gives
Dr. Logo a pattern to match. Dr. Logo can then erase any files whose names
match the pattern.
The wildcard character is a question mark ("?"). When the last character in
your input file name is a question mark, ERASEFILE erases any files whose
names begin with the characters that precede the question mark. (ROCHE> There
seems to be a bug in the version available, as ? does not work. To get
ambiguous file names, fill the name (and/or typ) field(s) with ?. Example: DIR
F???????.T??)
Examples:
Each of these examples assume you have two files named PIGLATIN and PLAID on
the disk in drive B. The first command erases only PIGLATIN.LOG. The second
command erases both files.
?erasefile "b:piglatin
?erasefile "b:p???????
(ROCHE> I found the following procedure useful...)
to era :fname
erasefile :fname
end
erasepic
--------
Action:
Erases the specified Dr. Logo image file.
Syntax:
erasepic fname
Explanation:
ERASEPIC erases a Dr. Logo image filename from a disk directory. You can enter
a drive name before the image filename to erase a image file not on the
default drive.
ERASEPIC accepts an ambiguous image filename as input. An ambiguous image
filename can refer to more than one image file because it contains a wildcard
character and gives Dr. Logo a pattern to match. Dr. Logo can then erase any
image files whose names match the pattern.
The wildcard character is a question mark ("?"). When the last character in
your input image filename is a question mark, ERASEPIC erases any image files
whose names begin with the characters that precede the question mark. (ROCHE>
There seems to be a bug in the version available, as ? does not work. To get
ambiguous file names, fill the name (and/or typ) field(s) with ?. Example: DIR
F???????.T??)
Examples:
Each of these examples assume you have two image files named PIGLATIN and
PLAID on the disk in drive B. The first command erases only PIGLATIN.LOG. The
second command erases both files.
?erasepic "b:piglatin
?erasepic "b:p???????
ern (= ERase one Name)
---
Action:
Erases the specified variable(s) from the workspace.
Syntax:
ern varname | varname_list
Explanation:
ERN erases a specified variable name or names from Dr. Logo's workspace. ERN
works by removing the .APV pair from the property list associated with the
variable name. If a variable has other property pairs in its list,
besides .APV, you must remove them with REMPROP to completely erase the
variable name from the workspace.
Examples:
Each of these examples assume you have two variables named BIG and SMALL in a
package named SIZE in your workspace.
?ern "big
This command erases the variable name BIG from Dr. Logo's workspace.
?ern [big small]
This command erases the variable names BIG and SMALL from Dr. Logo's
workspace.
?plist "big
[.PAK size .APV 80]
?ern "big
?plist "big
[.PAK size]
ERN removes only the .APV pair from a variable name's property list. Use
REMPROP to remove .PAK.
erns (= ERase several NameS)
----
Action:
Erases all the variables from the workspace or specified package(s).
Syntax:
erns < pkgname | pkgname_list >
Explanation:
ERNS erases a group of variable names from Dr. Logo's workspace. ERNS without
an input name erases all variable names from Dr. Logo's workspace, except for
any variable names in buried packages. You can give ERNS a package name or a
list of package names to specify a group of variables names to be erased. ERNS
can accept a buried package name as input; with this request, ERNS can remove
the value from a variable in a buried package.
ERNS works by removing the .APV pair from a variable name's property list. It
does not remove any other pair, such as the .PAK pair that indicates the name
is packaged. Therefore, after you use ERNS with a package name as input and
list the contents of the package with GLIST ".PAK, you will still see your
variable names listed under the package name, even though they have no values.
Examples:
These examples assume you have two packages named DRAW.PACK and MOVE.PACK in
your workspace.
?erns "draw.pack
This command erases all variable names from the DRAW.PACK package.
?erns [draw.pack move.pack]
This command erases all variable names from the DRAW.PACK and MOVE.PACK
packages.
erps (= ERase ProcedureS)
----
Action:
Erases all the procedures from the workspace or specified package(s).
Syntax:
erps < pkgname | pkgname_list >
Explanation:
ERPS erases a group of procedures from Dr. Logo's workspace. ERPS without an
input name erases all procedures from Dr. Logo's workspace, except for any
procedures in buried packages. You can give ERPS a package name or a list of
package names to specify a group of procedures to be erased. ERPS can accept a
buried package name as input; with this request, ERNS can remove the
definition from a procedure name in a buried package.
ERPS works by removing the .DEF pair from a procedure name's property list. It
does not remove any other property. Therefore, after you use ERPS with a
package name as input and list the contents of the package with GLIST ".PAK,
you will still see your procedure names listed as regular names under the
package name.
Examples:
These examples assume you have two packages named DRAW.PACK and MOVE.PACK in
your workspace.
?erps
This command erases all procedures, and leaves variables.
?erps "draw.pack
This command erases all procedures from the DRAW.PACK package.
?erps [draw.pack move.pack]
This command erases all procedure names from the DRAW.PACK and MOVE.PACK
packages.
erract (= ERRor ACTion) (Not a primitive)
------
Not a procedure, but a system variable.
When ERRACT is TRUE, any error causes a PAUSE, during which you can find the
origin of the error. Default = FALSE.
error
-----
Action:
Outputs a list whose elements describe the most recent error.
Syntax:
error
Explanation:
ERROR can output a list that describes the most recent error. If the most
recent error has already displayed a message on the screen, or if ERROR has
already output a list describing the most recent error, ERROR outputs an empty
list.
A non-empty ERROR output list contains six elements to describe an error:
1) A number that identifies the error. Dr. Logo error numbers are listed
in Appendix A, "Dr. Logo Error Messages".
2) A message that explains the error. This is the message that is usually
displayed on the screen.
3) The name of the procedure that contains the erroneous expression. If
the error occurred at toplevel, this element is an empty list.
4) The complete line that contains the erroneous expression.
5) The procedure name part of the erroneous expression, if any.
6) The input object part of the erroneous expression, if any.
Dr. Logo can take one of two actions when an error occurs. Which action Dr.
Logo takes depends on a system variable called ERRACT. The default state of
ERRACT is FALSE. You can set ERRACT to TRUE with a make statement.
While ERRACT is FALSE, Dr. Logo runs a THROW "ERROR command when an error
occurs. If no CATCH "ERROR command has been run, Dr. Logo terminates execution
of the procedure, prints an error message, and returns to toplevel. If the
error occurred within the scope of a CATCH "ERROR command, Dr. Logo returns to
the line following the CATCH "ERROR without displaying an error message on the
screen. This allows you to handle an error in your own way. The description of
the CATCH command gives an example of how to display a custom error message.
While ERRACT is TRUE, Dr. Logo does a PAUSE when an error occurs. During the
pause, you can execute an ERROR command to discover the cause of the error,
then change variables with MAKE or procedures with EDIT before entering CO to
continue execution of the procedure.
Examples:
?to safety.circle :size
>catch "error [repeat 180 [forward :size right 2]
>show error
>end
safety.circle defined
?safety.circle 2
[]
?safety.circle "two
[41 [forward doesn't like two as input] safety.circle [catch "error [repeat
180 forward :size right 2]]] forward rt]
.examine
--------
Action:
Displays the contents of a memory location.
Syntax:
.examine n
Explanation:
Displays the contents (a byte value) of the memory location specified by the
input number. This location is relative to the absolute location established
by .SETSEG. THIS PRIMITIVE SHOULD BE USED WITH CAUTION!
Examples:
?.examine 22
0
exp
---
Action:
Outputs the natural exponent of the input number.
Syntax:
exp n
Explanation:
EXP outputs the natural exponent of the input number.
Examples:
?exp 1
2.71828182845905
?log (exp 1)
1
fence
-----
Action:
Establishes a boundary that limits the turtle to onscreen plotting.
Syntax:
fence
Explanation:
FENCE establishes a boundary around the edge of the graphic screen. The fence
limits the turtle to onscreen plotting. When the turtle encounters the fence,
Dr. Logo displays a "Turtle out of bounds" message. The number of turtle steps
from home to the fence are as follows:
+100 +239
┌────────────┐ ┌────────────┐
│ setres 0 │ │ setres 1 │
-160 │ │ +159 -320 │ │ +319
│ 320x200 │ │ 640x480 │
└────────────┘ └────────────┘
-99 -240
To remove the fence, enter WINDOW.
Examples:
?to frame0 ?to frame1
>setres 0 >setres 1
>fs clean home >setscrunch 1
>pu setpos [-160 99] pd >setzoom 1
>setx 159 >fs clean home
>sety -99 >pu setpos [-320 239] pd
>setx -160 >setx 319
>sety 100 >sety -240
>pu home pd >setx -320
>end >sety 239
frame0 defined >pu home pd
?frame0 >end
Ctrl-G frame1 defined
?frame1
Ctrl-G
fill
----
Action:
Fills an area.
Syntax:
fill
Explanation:
Fills an area with the current pen color, by changing the dot under the turtle
(and all horizontally and vertically contiguous dots of the same color) to the
current pen color, using the current pen state. (ROCHE> To change the color of
the pen, use SETPC.)
Examples:
?fill
first
-----
Action:
Outpus the first element of the input object.
Syntax:
first object
Explanation:
FIRST outputs the first element of the input object. The first of a word or
number is a single character. The first of a list is either a word or a list.
FIRST of an empty word or empty list outputs an error.
Examples:
?first []
first doesn't like [] as input
?first "
first doesn't like an empty word as input
?first "rose
r
?first [weight 165]
weight
?to begin.vowelp :wrd
>output memberp first :wrd [a e i o u]
>end
begin.vowelp defined
?to pig :wrd
>if begin.vowelp :wrd
> [output word :wrd "ay]
> [output pig word (butfirst :wrd) (first :wrd)]
>end
pig defined
?to pig.latin :phrase
>if emptyp :phrase
> [output []]
>output sentence (pig first :phrase) (pig.latin butfirst :phrase)
>end
pig.latin defined
?pig.latin [a ball of string]
[aay allbay ofay ingstray]
follow
------
Action:
Reorganizes workspace, so that the first input-named procedure is followed by
the second.
Syntax:
follow procname procname
Explanation:
FOLLOW reorganizes the workspace, so that the first input-named procedure is
followed by the second. You can use FOLLOW to specify the order in which Dr.
Logo displays procedure titles and definitions (POALL, POPS, POTS, PROCLIST),
saves procedures on disk (SAVE), and loads procedures into the screen editor's
buffer (EDALL, EDPS). FOLLOW does not change the order of procedures in a
package definition.
Examples:
These examples assume you have three procedures named ZOOM, BUZZ, and FLY in a
package named FLY in your workspace.
?pots
zoom
fly
buzz
?popkg
fly
to zoom
to fly
to buzz
?follow "buzz "zoom
?pots "fly
fly
buzz
zoom
?popkg
fly
to zoom
to fly
to buzz
form (= real FORMat)
----
Action:
Outputs a number in real notation.
Syntax:
form n1 n2 < n3 >
Explanation:
Outputs a number, N1, with N2 digits before the decimal point, and N3 after
it. N2 must be a positive, real number from 1 through 15. If N2 is not an
integer, it is rounded to the nearest integer. If N3 is omitted, it is assumed
to be zero and the decimal point, and any digits after it, are not printed.
Examples:
?form 1.234 2
1
forward fd
----------
Action:
Moves the turtle the input number of steps in the direction of its current
heading.
Syntax:
forward distance_n
fd distance_n
Explanation:
FORWARD moves the turtle the input number of steps in the direction of its
current heading. If the turtle's pen is down, the turtle leaves a trace of its
path. On the IBM Personal Computer, a turtle step is equivalent to one dot
(pixel).
Examples:
?forward 100
?cs
?to plaid
>wrap
>setpc 3 right 40 forward 10965
>setpc 2 right 90 forward 5000
>setpc 1 penup right 90 forward 6 pendown ht
>repeat 625
> [forward 3 left 90 forward 1 right 90 back 3 left 90 forward 1 right 90]
>end
plaid defined
?plaid
fput (= First PUT)
----
Action:
Outputs a new object formed by making the first input object the first element
in the second input object.
Syntax:
fput object object
Explanation:
FPUT outputs a new object formed by making the first input object the first
element in the second input object. Generally, the new object is the same kind
of object as the second input object: a word, number, or list. However, when
you FPUT a word into a number, FPUT outputs a word.
Examples:
?fput "s "miles
smiles
?fput "banana [grape strawberry melon]
[banana grape strawberry melon]
?fput 20 20
2020
?fput [corn dog] [hamburger taco pizza]
[[corn dog] hamburger taco pizza]
?to exchange :from :to :in
>if emptyp :in
> [output []]
>if (first :in) = :from
> [output fput :to exchange :from :to butfirst :in]
> [output sentence first :in exchange :from :to butfirst :in]
>end
exchange defined
?exchange "cat "dog [My cat has fleas.]
[My dog has fleas.]
fullscreen fs
-------------
Action:
Selects full graphic screen.
Syntax:
fullscreen
fs
Explanation:
FULLSCREEN removes the SPLITSCREEN or TEXTSCREEN from the display, and
dedicates the monitor to graphics. FULLSCREEN is equivalent to a Ctrl-L
keystroke. Generally, it is easiest to use Ctrl-L when you are typing commands
at the keyboard, and FULLSCREEN (FS) from within a procedure.
Examples:
?repeat 12 [repeat 4 [forward 60 right 90] right 30]
?splitscreen
?fullscreen
glist (= Get property LIST)
-----
Action:
Outputs a list of all objects in the workspace or specified package(s) that
have the input property in their property lists.
Syntax:
glist prop < pkgname | pkgname_list >
Explanation:
With or without an input, GLIST outputs a list of objects that have the input
property in their property lists. Without an input, GLIST checks the property
lists of all objects in the workspace. If you specify a package name or a list
of packages in the GLIST expression, GLIST checks only the objects in the
specified package(s).
Property lists and Dr. Logo's system properties are described in Section 5,
"Property Lists, Workspace, and Disks". To understand the examples below,
remember that .DEF is the system property Dr. Logo gives to defined
procedures.
Examples:
These examples assume that, in your workspace, you have packages named FLY and
PIGLATIN.
?glist ".DEF
[countdown pig.latin begin.vowelp fly buzz triangle.text zoom pig]
?glist ".DEF "fly
[fly buzz zoom]
?glist ".DEF [fly pig.latin]
[pig.latin begin.vowelp fly buzz zoom pig]
?sort glist ".PRM
[() * + - .contents .deposit .examine .in .out .replace .reptail .setseg / <
<= <> = =< => > >< >= ^ abs allopen and arctan ascii back bf bk bl bury
butfirst butlast catch changef char clean clearscreen cleartext close closeall
co copydef copyoff copyon cos count cs ct cursor defaultd define definedp
degrees dir dirpic dot dotc ed edall edf edit edns edps eform emptyp equalp er
erall erase erasefile erasepic ern erns erps error exp fd fence fill first
follow form forward fput fs fullscreen glist go gprop heading help hideturtle
home ht if iff iffalse ift iftrue int item keyp label last lc left list listp
load loadpic local log log10 lowercase lput lt make memberp mouse name namep
nodes noformat not notrace nowatch numberp op open or output package pal pause
pd pe pendown penerase penreverse penup pi piece pkgall plist po poall pocall
pons popkg pops poref pos potl pots pprop pps pr prec primitivep print
proclist product pu px quotient radians random rc readchar readeofp reader
readlist readquote recycle remainder remprop repeat rerandom right rl round rq
rt run save savepic screenfacts se sentence setbg setcursor setd seth
setheading setpal setpan setpc setpen setpos setprec setread setres setscrunch
setsplit setwrite setx sety setzoom sf show showturtle shuffle sin sort
splitscreen sqrt ss st stop sum tan test text textscreen tf thing throw tones
towards trace ts tt turtlefacts turtletext type uc unbury uppercase wait watch
where window word wordp wrap writer xcor ycor]
go
--
Action:
Executes the line within the current procedure identified by LABEL and the
input word.
Syntax:
go word
Explanation:
GO executes the line within the current procedure identified by LABEL and the
input word. This means that, after GO, Dr. Logo will next execute the line
following the LABEL expression. The GO and LABEL expressions must have the
same input word, and be in the same procedure.
GO and LABEL let you change the sequence in which Dr. Logo executes the lines
in a procedure. Therefore, GO and LABEL cannot be on the same line. This means
you cannot use GO and LABEL within an instruction list input to REPEAT, RUN,
or the IFs.
Examples:
?to triangle.text :string
>label "loop
>if emptyp :string
> [stop]
>print :string
>make "string butfirst :string
>go "loop
>end
triangle.text defined
?triangle.text [Get along little dogie.]
Get along little dogie.
along little dogie.
little dogie.
dogie.
?to countdown :n
>label "loop
>if :n < 0
> [stop]
>type :n
>make "n (:n - 1)
>go "loop
>end
countdown defined
?countdown 9
9876543210
gprop (= Get PROPerty)
-----
Action:
Outputs the value of the input-named property of the input-named object.
Syntax:
gprop name prop
Explanation:
GPROP outputs the value of the input-named property of the input-named object.
The input name identifies the object that has the property. If the object does
not have the input-named property, GPROP outputs an empty list.
Section 5, "Property Lists, Workspace, and Disks", describes property lists,
and defines the properties Dr. Logo gives to objects in the workspace. To
understand the examples below, remember that a property list is made up of
property pairs. The first element of the pair is the property; the second, its
value. Dr. Logo gives defined procedures the .DEF property, and defined
variables the .APV property.
Examples:
This example assumes you have a procedure named pig in your workspace.
?gprop "pig ".DEF
[[wrd] if begin.vowelp :wrd [output word :wrd "ay]
[output ! pig word (butfirst :wrd) (first :wrd)]]
?make "height "72"
?gprop "height ".APV
72"
?gprop "height ".DEF
[]
heading
-------
Action:
Outputs a number that indicates the turtle's current heading.
Syntax:
heading
Explanation:
HEADING outputs the turtle's current heading as a real number between 0 and
359 inclusive. The turtle's heading corresponds to traditional compass
headings:
Degrees Direction Pointing
------- --------- --------
0 North up
90 East right
180 South down
270 West left
Examples:
?home show heading
0
?right 1 show heading
1
?right 1 show heading
2
?left random 360 heading
126
?to compass :n
>if memberp :n
> [0 90 180 270] [points]
>if (:n > 360)
> [stop]
>(type heading char 9)
>right 5 penup forward 25 pendown forward 5 penup back 30
>compass :n + 5
>end
compass defined
?to points
>pu
>forward 40
>if :n = 0
> [turtletext "N]
>if :n = 90
> [turtletext "E]
>if :n = 180
> [turtletext "S]
>if :n = 270
> [turtletext "W]
>setpos [0 0]
>end
points defined
?compass 0
help
----
Action:
Displays the names and abbreviations of all Dr. Logo primitives.
Syntax:
help < primitive >
Explanation:
HELP displays the names and abbreviations of all Dr. Logo primitives.
HELP displays only 25 lines on the screen at a time. It waits for you to press
any key before displaying the next 25 lines.
Examples:
?help
HELP displays the list of all Dr. Logo primitives. Press any key to view next
screenful of names.
hideturtle ht
-------------
Action:
Makes the turtle invisible.
Syntax:
hideturtle
ht
Explanation:
HIDETURTLE makes the turtle invisible. When invisible, the turtle draws faster
and does not distract visually from the drawing. To make the turtle visible
again, enter SHOWTURTLE.
Examples:
?hideturtle
?showturtle
?to star :size
>repeat 5
> [forward :size left 217 forward :size left 71]
>end
star defined
?star 30
?ht
home
----
Action:
Returns the turtle to position [0 0] (the center of the graphic screen)
heading 0 (North).
Syntax:
home
Explanation:
HOME positions the turtle at "home", position [0 0] (the center of the
screen), heading 0 (North). HOME is the position in which the turtle first
appears when you start Dr. Logo.
HOME does not change the turtle's pen state. For example, if the turtle's pen
is down when HOME is executed, the turtle draws a line from its current
loation to the center of the screen.
Examples:
?forward 80 left 120 forward 80
?home
if
--
Action:
Executes one of two instructions lists, depending on the value of the input
predicate expression.
Syntax:
if pred_exp instr_list < instr_list >
Explanation:
IF transfers execution to one of two instruction lists, depending on the TRUE
or FALSE value of the input predicate expression. You can use an IF expression
to make a decision regarding the flow of control within your procedure.
The first input to IF must be a predicate expression, one that outputs TRUE or
FALSE. If the predicate outputs TRUE, Dr. Logo executes the first instruction
list. If the predicate outputs FALSE, Dr. Logo executes either the second
instruction list (if any), or the next line in the procedure.
IF requires literal instruction lists as input; that is to say, an instruction
list input to IF must be enclosed in square brackets ("[" and "]"). Dr. Logo
allows nested IF expressions. This means you can use an IF statement within an
instruction list you input to IF.
Examples:
?setheading random 360
?if heading < 180 [print "East] [print "West]
West
The COIN procedures that follow demonstrate several ways to use IF. COIN1
shows IF making a simple decision between two input instruction lists.
?to coin1
>if 1 = random 2
> [print "heads]
> [print "tails]
>end
coin1 defined
COIN2 shows IF providing input to another procedure.
?to coin2
>print if 1 = random 2 ["heads] ["tails]
>end
coin2 defined
COIN3 shows how IF executes the next line in a procedure if no second
instruction list is input.
?to coin3
>if 1 = random 2
> [output "heads]
>output "tails
>end
coin3 defined
COIN4 shows how the second instruction list makes the line following the IF
expression independent of the results of the IF test.
?to coin4
>if 1 = random 2
> [type "heads]
> [type "tails]
>print [\ side up]
>end
coin4 defined
iffalse iff
-----------
Action:
Executes the input instruction list if the most recent test was FALSE.
Syntax:
iffalse instr_list
iff instr_list
Explanation:
IFFALSE executes its input instruction list if the result of the most recent
TEST expression was FALSE. If the result of test was TRUE, IFFALSE does
nothing.
You can use TEST, IFFALSE, and IFTRUE as an alternate to IF to control the
flow of execution within your procedure. These primitives are particularly
useful when you need Dr. Logo to evaluate expressions after it evaluates a
predicate expression, but before it executes the chosen instruction list.
IFFALSE requires a literal instruction list as input; that is to say, any
instruction list you input to IFFALSE must be enclosed in square brackets ("["
and "]"). Dr. Logo allows nested IF expressions. This means you can use TEST,
IFFALSE, and IFTRUE within the instruction list you input to IFFALSE.
Examples:
The COIN5 procedure is similar to the COIN procedures shown as examples under
if, but shows how to use TEST, IFFALSE, and IFTRUE. COIN5 evaluates a
expression after it evaluates a predicate expression, but before it executes
the chosen instruction list.
?to coin5
>test 1 = random 2
>if 1 = random 1000000
> [print [Landed on edge!] stop]
>iftrue [type "heads]
>iffalse [type "tails]
>print [\ side up]
>end
coin5 defined
iftrue ift
----------
Action:
Executes the input instruction list if the most recent test was TRUE.
Syntax:
iftrue instr_list
ift instr_list
Explanation:
IFTRUE executes its input instruction list if the result of the most recent
TEST expression was TRUE. If the result of test was FALSE, IFTRUE does
nothing.
You can use TEST, IFFALSE, and IFTRUE as an alternate to IF to control the
flow of execution within your procedure. These primitives are particularly
useful when you need Dr. Logo to evaluate expressions after it evaluates a
predicate expression, but before it executes the chosen instruction list.
IFTRUE requires a literal instruction list as input; that is to say, any
instruction list you input to IFTRUE must be enclosed in square brackets ("["
and "]"). Dr. Logo allows nested IF expressions. This means you can use TEST,
IFFALSE, and IFTRUE within the instruction list you input to IFFALSE.
Examples:
The COIN5 procedure is similar to the COIN procedures shown as examples under
IF, but shows how to use TEST, IFFALSE, and IFTRUE. COIN5 evaluates a
expression after it evaluates a predicate expression, but before it executes
the chosen instruction list.
?to coin5
>test 1 = random 2
>if 1 = random 1000000
> [print [Landed on edge!] stop]
>iftrue [type "heads]
>iffalse [type "tails]
>print [\ side up]
>end
coin5 defined
.in
---
Action:
Displays the contents of a I/O port.
Syntax:
.in port_n
Explanation:
Displays the contents (a byte value) of the specified I/O port. Port numbers
range from 0 to 65535.
Examples:
?.in 397
50
int
---
Action:
Outputs the integer portion of the input number.
Syntax:
int n
Explanation:
INT outputs the integer portion of the input number. INT discards any decimal
point and subsequent numerals from the input number. To round a decimal number
to the nearest integer, use ROUND.
Examples:
?int 3.333333
3
?int 3
3
?int 28753 / 12
2396
?int -75.482
-75
?to integerp :n
>if numberp :n
> [output :n = int :n]
>(print :n [is not a number.]
>end
integerp defined
?integerp 6.65
FALSE
?integerp 6
TRUE
?integerp "six
six is not a number.
item
----
Action:
Outputs the specified element of the input object.
Syntax:
item n object
Explanation:
ITEM outputs an element of the input object. The input number specifies which
element of the input object ITEM outputs.
Examples:
?item 4 "dwarf
r
?item 2 [brownie snickerdoodle wafer]
snickerdoodle
?make "favorites [brownie snickerdoodle [oatmeal raisin]]
?count item 3 :favorites
2
?to make.sentence :n :v
>print (sentence item ((random (count :n)) + 1) :n
> item ((random (count :v)) + 1) :v
>end
make_sentence defined
?make_sentence [elephants crocodiles mambasnakes] [pirouette tapdance
rollerskate]
mambasnakes pirouette
keyp (= KEY Predicate)
----
Action:
Outputs TRUE is a character has been typed at the keyboard, and is waiting to
be read.
Syntax:
keyp
Explanation:
KEYP outputs TRUE if a character has been typed at the keyboard, and is
waiting to be read by READCHAR, READQUOTE, or READLIST.
When you type a character at toplevel, Dr. Logo displays the character on the
screen. However, while a procedure is executing, Dr. Logo stores any
characters that are typed at the keyboard in a buffer, and displays them on
the screen when the procedure ends. By using KEYP in a procedure, you can
discover whether or not your user has typed something while your procedure is
executing.
What your user types into the buffer is critical if your procedure contains
subsequent READQUOTE, READCHAR, or READLIST expressions that read the buffer
and input its contents to the rest of your procedure. You can use KEYP to
determine if your user has typed something, then check that the buffer
contains the kind of input your procedure requires before passing the input to
the procedure.
Examples:
?to sketch
>forward 2
>wait 10
>if keyp
> [turn readchar]
>sketch
>end
sketch defined
?to turn :way
>if ascii :way = 6 ; Right Arrow key
> [right 10]
>if ascii :way = 2 ; Left Arrow key
> [left 10]
>end
turn defined
?sketch
?to delay
>print [Any keystroke delays next number by a second.]
>print.out
>end
delay defined
?to print.out
>if keyp
> [wait 60 sink readchar]
>(type random 10 char 9)
>print.out
>end
print.out defined
?to sink :object
>end
sink defined
Any keystroke delays next number by a second.
6 9 2 5 8 0 3 6 1 9 1 0 6 1 3 5 1 8 0 1
7 Ctrl-G
?to count.stars
>make "number 1 + random 10
>draw.stars :number
>print [How many stars?]
>label "back
>if keyp
> [make buffer readquote
> (if not numberp first :buffer
> [ern "buffer go "back]
> [go on])]
> [go "back]
>label "on
>if :number = :buffer
> [print "Right!]
> [print [Wrong! There are] :number]
>cs
>count.stars
>end
count.stars defined
?to draw.stars :number
>if :number = 0>
> [stop]
>penup setpos list
> (random 100 * first shuffle [1 -1])
> (random 70 * first shuffle [1 -1])
>pendown star pu
>draw.stars :number - 1
>end
draw.stars defined
?to star2 ; Five pointed star
>repeat 5
> [forward 30 left 127 forward 30 left 70]
>end
star2 defined
?count.stars
How many stars?
4
Right!
How many stars?
5
Right!
How many stars?
6
Wrong! There are 5
How many stars? Ctrl-G
Stopped! in count.stars: go
label
-----
Action:
Identifies the line to be executed after a GO expression.
Syntax:
label word
Explanation:
LABEL identifies the line to be executed after a GO expression. The LABEL and
GO expressions must be in the same procedure, and have the same input word.
GO and LABEL let you change the sequence in which Dr. Logo executes the lines
in a procedure. Therefore, GO and LABEL cannot both be on the same line. This
means you cannot use both GO and LABEL within an instruction list input to
REPEAT, RUN, or the IFs.
Examples:
?to triangle.text :string
>label "loop
>if emptyp :string
> [stop]
>print :string
>make "string butfirst :string
>go "loop
>end
triangle.text defined
?triangle.text [Wyoming will be your new home.]
Wyoming will be your new home.
will be your new home.
be your new home.
your new home.
new home.
home.
?to countdown :n
>label "loop
>if :n < 0
> [stop]
>type :n
>make "n (:n - 1)
>go "loop
>end
countdown defined
?countdown 9
9876543210
last
----
Action:
Outputs the last element of the input object.
Syntax:
last object
Explanation:
LAST outputs the last element of the input object. The last of a word or
number is a single character. The last of a list is either a word or a list.
LAST of an empty word or empty list outputs an error.
Examples:
?last []
last doesn't like [] as input
?last "
last doesn't like an empty word as input
?last "skyline
e
?last [weight 165]
165
?to mirror :word
>(print reverse :word "| :word
>end
mirror defined
?to reverse :word
>if emptyp :word
> [output "]
>output (word last :word reverse butlast :word)
>end
reverse defined
?mirror "mirror
rorrim | mirror
left lt
-------
Action:
Rotates the turtle the input number of degrees to the left.
Syntax:
left degrees_n
lt degrees_n
Explanation:
LEFT rotates the turtle the input number of degrees to the left. Usually, you
input a number of degrees between 0 and 359. If the input number is greater
than 359, the turtle appears to move the input number minus 360 degrees to the
left. If you input a negative number to LEFT, the turtle turns to the right.
Examples:
?repeat 36 [left 10]
?repeat 36 [left -10]
?to around.L :s
>repeat 360
> [forward :s left 10 make "s :s + .01]
>end
around.L defined
?around.L 2
list
----
Action:
Outputs a list made up of the input objects.
Syntax:
list object object (...)
Explanation:
LIST outputs a list made up of the input objects. LIST is like SENTENCE, but
does not remove the outermost brackets from an input object.
Without punctuation, LIST requires and accepts two input objects. LIST can
accept more or fewer inputs when you enclose the LIST expression in
parentheses ["(" and ")"]. If no other expressions follow the LIST expression
on the line, you do not need to type the closing right parenthesis [")"].
There are two ways of creating lists in Dr. Logo:
1) using square brackets ("[" and "]")
2) using LIST or SENTENCE
Each way results in a different kind of list. When you create a list by
enclosing elements in square brackets ("[" and "]"), you create a "literal"
list. Dr. Logo treats the elements of the list literally; it does not evaluate
expressions or look up the values of variables named in a literal list.
When you use LIST or SENTENCE to create a list, you can use variables and
expressions to specify the elements Dr. Logo will put in the list. You can use
list and sentence to create a list for input to most procedures. However, IF,
IFFALSE, and IFTRUE require literal lists as input.
Examples:
?show list "big "feet
[big feet]
?list "potatoes [mashed baked fried]
[potatoes [mashed baked fried]]
?(list
[]
?(list 21 22 23 24
[21 22 23 24]
?to square
>repeat 4
> [forward 60 right 90]
>end
square defined
?make "procname "square
?run (list :procname
?to zip.zap
>setpos list
> random 150 * first shuffle
> random 100 * first shuffle
>zip.zap
>end
zip.zap defined
?zip.zap
listp (= LIST Predicate)
-----
Action:
Outputs TRUE if the input object is a list.
Syntax:
listp object
Explanation:
LISTP outputs TRUE if the input object is a list. Otherwise, LISTP outputs
FALSE.
Examples:
?listp "force
FALSE
?listp [father brother sister]
TRUE
?listp "
FALSE
?listp []
TRUE
?to reflect :object
>if listp :object
> [print reverse.list :object]
> [print reverse :object]
>end
reflect defined
?to reverse.list :list
>if emptyp :list
> [output "]
>output (sentence last :list reverse.list butlast :list
>end
reverse.list defined
?to reverse :word
>if emptyp :word
> [output "]
>output (word last :word reverse butlast :word
>end
reverse defined
?reflect "skywalker
reklawyks
?reflect [wherever you go]
go you wherever
load
----
Action:
Reads the input-named Dr. Logo file from the disk into the workspace.
Syntax:
load fname < pkgname >
Explanation:
LOAD reads the contents of the input-named Dr. Logo file from disk into the
workspace. You can precede the file name with a drive specifier if the file is
not on the default drive.
Dr. Logo defines each procedure and variable as it is read in from the disk.
If a procedure in the workspace has the same name as a procedure read in from
the disk, the procedure in the workspace is overwritten.
LOAD can load only those files saved with a SAVE command (files with the file
type LOG in the disk directory). You can load only one file at a time. When
you interrupt LOAD with Ctrl-G or Ctrl-Z, LOAD stops reading from the Dr. Logo
file, and defines only those procedures displayed on your screen.
LOAD can accept a package name as an optional input after the file name. LOAD
then puts all items read from the file in the input-named package.
Examples:
These examples assume you have a Dr. Logo file named PIGLATIN on the disk in
the default drive, and a file named FLY on the disk in drive B.
?load "piglatin
begin.vowelp defined
pig defined
pig.latin defined
?load "b:fly
fly defined
buzz defined
zoom defined
loadpic
-------
Action:
Reads the input-named image file from the disk into the screen.
Syntax:
loadpic fname
Explanation:
LOADPIC reads the contents of the input-named image file from disk into the
screen. You can precede the file name with a drive specifier if the file is
not on the default drive.
LOADPIC can load only those files saved with a SAVEPIC command (files with the
file type PC0 in the disk directory). (ROCHE> for SETRES 0 images. But images
saved under SETRES 1 are given the PC1 file type... and DIRPIC is then unable
to find them! This is clearly a bug. The solution is to use an ambiguous
filespec, with .PC? for the file type.) You can load only one file at a time.
Examples:
?loadpic "shapes
?dirpic
[SHAPES.PC0 PLAID.PC0 PIGLATIN.PC0]
?dirpic "p???????.pc?
[PLAID.PC0 PIGLATIN.PC0 PLAID.PC1 PIGLATIN.PC1]
local
-----
Action:
Makes the input-named variable(s) accessible only to the current procedure and
the procedures it calls.
Syntax:
local var_name (...)
Explanation:
LOCAL makes the input-named variables "local" to the procedure in which the
LOCAL expression occurs. Local variables can be changed by the procedure in
which the LOCAL expression occurs, or by any procedure it calls.
Without punctuation, LOCAL requires and accepts one input name. LOCAL can
accept more inputs when you enclose the LOCAL expression in parentheses ["("
and ")"]. If no other expressions follow the LOCAL expression on the line, you
do not need to type the closing right parenthesis [")"].
Most frequently, you will use variables of the same name within calling and
called procedures, to pass information between the two procedures. However,
you will also find applications where you do not want the called procedure to
modify the calling procedure's value of the variable. If calling and called
procedures are using variables of the same name, which is unavoidably the case
when a procedure calls itself, a LOCAL expression in the called procedure
prevents the called procedure from altering the calling procedure's value of
the variable.
Examples:
DRAWING.REPORT and DRAW.CIRCLE both use X and Y as variable names. The LOCAL
expression in DRAW.CIRCLE prevents DRAW.CIRCLE from modifying DRAWING.REPORT's
values of X and Y. Without the LOCAL expression in DRAW.CIRCLE, DRAWING.REPORT
would print CIRCLE.FINISHED at the point where the turtle began drawing the
circle.
?to drawing.report
>make "x (-150)
>make "y 80
>penup setpos list :x :y
>turtletext "drawing.circle
>draw.circle
>setpos list :x :y
>turtletext "circle.finished setheading 0 forward 10
>end
drawing.report defined
?to draw.circle
>(local "x "y)
>make "x 10
>make "y 50
>penup setpos list :x :y setheading 90
>pendown repeat 36 [forward 10 right 10] pu
>end
draw.circle defined
?drawing.report
The LOCAL statement in DECIMAL.OF.FRACTION forces Dr. Logo to create a new
variable named INVERSE each time DECIMAL.OF.FRACTION calls itself. (ROCHE> I
don't know why, but all the sample Dr. Logo programs from Digital Research
have opening and closing parentheses ["(" and ")"] surrounding LOCAL
statements, even if there is only one variable name, like below.)
?to decimal.of.fraction :n
>(local "inverse)
>make "inverse 1 / :n
>if :n = 1
> [stop]
>decimal.of.fraction :n - 1
>(print ["1/] :n char 9 :inverse
>end
decimal.of.fraction defined
?decimal.of.fraction 10
1/ 2 0.5
1/ 3 0.333333333333333
1/ 4 0.25
1/ 5 0.2
1/ 6 0.166666666666667
1/ 7 0.142857142857143
1/ 8 0.125
1/ 9 0.111111111111111
1/ 10 0.1
log
---
Action:
Outputs the natural logarithm of the input number.
Syntax:
log n
Explanation:
LOG outputs the natural logarithm of the input number. A natural logarithm is
the logarithm to the base e, where e = 2.71828182845905.
Examples:
?log 1
0
?log (exp 1)
1
?log (180 / pi)
4.04822696504081
log10
-----
Action:
Outputs the base 10 logarithm of the input number.
Syntax:
log10 n
Explanation:
LOG10 outputs the base 10 logarithm of the input number.
Examples:
?log10 100
2
?log10 734
2.86569605991607
?log10 3950
3.59659709562646
lowercase lc
------------
Action:
Outputs the input word with all alphabetic characters in lowercase.
Syntax:
lowercase word
lc word
Explanation:
LOWERCASE outputs the input word with all alphabetic characters converted to
lower case.
Examples:
?lowercase "SOUTH
south
?lowercase "MaryAnn
maryann
?to quiz
>print [Do you like chocolate chip cookies?]
>if "y = lowercase first readquote
> [print [I do too!]]
> [print [Wow, I have never met anyone who did not!]
>end
quiz defined
?quiz
Do you like chocolate chip cookies?
YES!!!
I do too!
lpen (= LightPEN) (Not a primitive)
----
Action:
Outputs a coordinate list that indicates the position of the lightpen.
Syntax:
lpen
Explanation:
LPEN outputs the position where the lightpen first touched the screen since
the last LPEN expression. LPEN represents the lightpen's position in the same
way cursor represents the cursor location on a 40 column text screen. Both
LPEN and CURSOR use a coordinate system that originates at the upper left
corner of the display.
[0 0] [39 0]
┌───────────────────┐
│ │
│ │
│ │
│ │
│ │
└───────────────────┘
[0 24] [39 24]
Examples:
SKETCH shows how to use LPENP to determine whether or not the lightpen has
been used before trying to read the lightpen's position with LPEN. If there is
no lightpen input waiting to be read when Dr. Logo executes a LPEN expression,
LPEN outputs [0 0].
CONVERTX and CONVERTY show a way to convert from lightpen coordinates into
turtle graphics coordinates.
?to sketch
>forward 2
>wait 10
>if lpenp
> [turn.to lpen]
>sketch
>end
sketch defined
?to turn.to :position
>convert.x convert.y
>(print :position "= list :x :y)
>setheading towards list :x :y
>sketch
>end
turn.to defined
?to convert.x
>make "x (first :position) * 7.5 - 150
>end
convert.x defined
?to convert.y
>make "y (last :position) * (-8) + 100
>end
convert.y defined
?sketch
lpenp (= LightPEN Predicate) (Not a primitive)
-----
Action:
Outputs TRUE if lightpen input is waiting to be read.
Syntax:
lpenp
Explanation:
LPENP outputs TRUE if lightpen input is waiting to be read. Use LPENP in an IF
statement to determine whether or not the lightpen has been used, before
trying to read the lightpen's position with LPEN (see LPEN).
Examples:
?to sketch
>forward 2
>wait 10
>if lpenp
> [turn.to lpen]
>sketch
>end
sketch defined
?to turn.to :position
>convert.x convert.y
>(print :position "= list :x :y)
>setheading towards list :x :y
>sketch
>end
turn.to defined
?to convert.x
>make "x (first :position) * 7.5 - 150
>end
convert.x defined
?to convert.y
>make "y (last :position) * (-8) + 100
>end
convert.y defined
?sketch
lput (= Last PUT)
----
Action:
Outputs a new object formed by making the first input object the last element
in the second input object.
Syntax:
lput object object
Explanation:
LPUT outputs a new object formed by making the first input object the last
element in the second input object. Generally, the new object is the same kind
of object as the second input object: a word, number, or list. However, when
you LPUT a word into a number, LPUT outputs a word.
Examples:
?lput "s "plural
plurals
?lput "s [plural]
[plural s]
?lput "cherries [apples bananas]
[apples bananas cherries]
?lput [San Jose] [[San Diego] [San Francisco]]
[[San Diego] [San Franscico] [San Jose]]
?make "extensions [[Hal 33] [John 85]]
?to add.entry :item
>make "extensions lput :item :extensions
>end
add.entry defined
?add.entry [Steve 96]
?:extensions
[[Hal 33] [John 85] [Steve 96]]
make
----
Action:
Makes the input object the value of the input-named variable.
Syntax:
make varname object
Explanation:
MAKE makes the input object the "contents" or value of the input-named
variable. If the input-named variable does not exist, MAKE creates it. If the
input-named variable already exists, MAKE discards its current contents and
gives it the input object as a value.
MAKE works just like NAME, except that the order of the inputs are reversed.
MAKE works by adding the system property .APV with the value of the input
object to the input-named variable's property list.
Examples:
?make "flavor "chocolate
?:flavor
chocolate
?make "chocolate "semi\-sweet
?:chocolate
semi-sweet
?thing "flavor
chocolate
?thing :flavor
semi-sweet
?to say.hello
>print [Hello! What is your name?]
>make "answer readquote
>(print [Nice to meet you,] word :answer ".
>end
say.hello defined
?say.hello
Hello! What is your name?
Oscar
Nice to meet you, Oscar.
memberp (= MEMBER Predicate)
-------
Action:
Outputs TRUE if the first input object is an element of the second input
object.
Syntax:
memberp object object
Explanation:
MEMBERP outputs TRUE if the first input object is an element of the second
input object; otherwise, MEMBERP outputs FALSE.
Examples:
?memberp "y "only
TRUE
?memberp 7 734395
TRUE
?memberp "or "chore
TRUE
?memberp "chocolate [[vanilla] [chocolate] [strawberry]]
FALSE
?memberp [chocolate] [[vanilla] [chocolate] [strawberry]]
TRUE
?to vowelp :object
>if memberp :object [a e i o u]
> [output "TRUE]
> [output "FALSE]
>end
vowelp defined
?vowelp "c
FALSE
?vowelp "i
TRUE
mouse
-----
Action:
Outputs a list giving the state of the mouse.
Syntax:
mouse
Explanation:
Outputs a list giving the state of the mouse.
Examples:
?mouse
[-160 100 FALSE FALSE FALSE]
where:
the first item (-160) is the mouse X-coordinate
the second item (100) is the mouse Y-coordinate
the third item (FALSE) is the mouse left button
the fourth item (FALSE) is the mouse right button
the fifth item (FALSE) is a predicate saying if the mouse is inside the
graphic window
(The above mouse list was gotten from text screen.)
name
----
Action:
Makes the input object the value of the input-named variable.
Syntax:
name object var_name
Explanation:
NAME makes the input object the "contents" or value of the input-named
variable. If the input-named variable does not exist, NAME creates it. If the
input-named variable already exists, NAME discards its current contents and
gives it the input object as a value.
NAME works just like MAKE, except that the order of the inputs are reversed.
NAME works by adding the system property .APV with the value of the input
object to the input-named variable's property list.
Examples:
?name "flavor "chocolate
?:flavor
chocolate
?name "chocolate "semi\-sweet
?:chocolate
semi-sweet
?thing "flavor
chocolate
?thing :flavor
semi-sweet
namep (= NAME Predicate)
-----
Action:
Outputs TRUE if the input word identifies a defined variable.
Syntax:
namep word
Explanation:
NAMEP outputs TRUE if the input word identifies a defined variable. Otherwise,
NAMEP outputs FALSE.
Examples:
?make "flavor "chocolate
?:flavor
chocolate
?namep "flavor
TRUE
?namep "raspberry
FALSE
?to decrement :name
>if not namep :name
> [print [Not a variable.]]
>if numberp thing :name
> [make :name (thing :name) - 1]
>end
decrement defined
?make "age 14
?decrement "age
?:age
13
nodes
-----
Action:
Outputs the number of free nodes in the workspace.
Syntax:
nodes
Explanation:
NODES outputs the number of free nodes in the workspace. A node is equal to
one byte. (ROCHE> In general, you have 59KB of memory to play with. Four times
the size of the workspace of the 8-bits version of Dr. Logo...)
Examples:
?nodes
55702
?recycle
?nodes
59524
noformat
--------
Action:
Removes comments from the workspace.
Syntax:
noformat
Explanation:
NOFORMAT removes comments from the workspace, to free more nodes. NOFORMAT
works by removing any .FMT property pairs from a procedure's poperty list.
Examples:
?to bg.cycle :val ; Displays background colors
>if :val = 0
> [print [Cycle complete.] setbg 0 stop]
>setbg :val
>(print [This is background color number] first screenfacts)
>wait 20000 ; 2 seconds on a 500-MHz PC
>bg.cycle :val - 1
>end
bg.cycle defined
?noformat
?po "bg.cycle :val
bg.cycle :val
if :val = 0 [print [Cycle complete.] setbg 0 stop]
setbg :val
(print [This is background color number] first screenfacts)
wait 20000
bg.cycle :val - 1
end
not
---
Action:
Outputs TRUE if the input predicate outputs FALSE, FALSE if input predicate
outputs TRUE.
Syntax:
not pred_exp
Explanation:
NOT reverses the value of a predicate expression. If the input predicate
outputs TRUE, NOT outputs FALSE. If the input predicate outputs FALSE, NOT
outputs TRUE.
Examples:
?not 2 > 1
FALSE
?not 2 < 1
TRUE
?to inverse :n
>if not numberp :n
> [(print :n [is not a number.]) stop]
>(print "1\ / :n "= 1 / :n
>end
inverse defined
?inverse 5
1 / 5 = 0.2
?inverse "five
five is not a number.
notrace
-------
Action:
Turns off trace monitoring of all or specified procedure(s).
Syntax:
notrace < procname | procname_list >
Explanation:
NOTRACE turns off the monitoring of procedure execution initiated by a TRACE
command.
Examples:
?to average :numbers
>make "total 0
>add.up :numbers
>print :total / count :numbers
>end
average defined
?to add.up :list
>if emptyp :list
> [stop]
>make "total :total + first :list
>add.up butfirst :list
>end
add.up defined
?trace
?average [1 2 3]
[1] Evaluating average
[1] numbers is [1 2 3]
[2] Evaluating add.up
[2] list is [1 2 3]
[3] Evaluating add.up
[3] list is [2 3]
[4] Evaluating add.up
[4] list is [3]
[5] Evaluating add.up
[5] list is []
2
?notrace
?average [1 2 3]
2
nowatch
-------
Action:
Turns off watch monitoring of all or specified procedure(s).
Syntax:
nowatch < procname | procname_list >
Explanation:
NOWATCH turns off the monitoring of procedure execution initiated by a WATCH
command.
Examples:
?to average :numbers
>make "total 0
>add.up :numbers
>print :total / count :numbers
>end
average defined
?to add.up :list
>if emptyp :list
> [stop]
>make "total :total + first :list
>add.up butfirst :list
>end
add.up defined
?watch
?average [1 2 3]
[1] In average, make "total 0
[1] In average, add.up :numbers
[2] In add.up, if emptyp :list [stop]
[2] In add.up, make "total :total + first :list
[2] In add.up, add.up butfirst :list
[3] In add.up, if emptyp :list [stop]
[3] In add.up, make "total :total + first :list
[3] In add.up, add.up butfirst :list
[4] In add.up, if emptyp :list [stop]
[4] In add.up, make "total :total + first :list
[4] In add.up, add.up butfirst :list
[5] In add.up, if emptyp :list [stop]
[5] In average, print :total / count :numbers
2
?nowatch
?average [1 2 3]
2
numberp (= NUMBER Predicate)
-------
Action:
Outputs TRUE if the input object is a number.
Syntax:
numberp object
Explanation:
NUMBERP outputs TRUE if the input object is a number; otherwise, NUMBERP
outputs FALSE.
Examples:
?numberp 374.926
TRUE
?numberp "six
FALSE
?numberp first [2 4 6 8]
TRUE
?numberp butfirst [2 4 6 8]
FALSE
?to inverse :n
>if not numberp :n
> [(print :n [is not a number.]) stop]
>(print "1\ / :n "= 1 / :n
>end
inverse defined
?inverse 2
1 / 2 = 0.5
?inverse "two
two is not a number.
open
----
Action:
Open a file or device.
Syntax:
open < fname | device >
Explanation:
Open the file or device to send or receive characters. OPEN must be used
before accessing data in a file.
(ROCHE> The devices are: CON: NUL: PRN: and AUX: There is a system message,
saying that "Only 4 files can be open".)
Examples:
?open "letters
or
--
Action:
Outputs FALSE if all input predicates outputs FALSE.
Syntax:
or pred_exp pred_exp (...)
Explanation:
OR outputs FALSE if all input predicates output FALSE. If any input predicate
outputs FALSE, OR outputs TRUE.
Without punctuation, OR requires and accepts two input objects. OR can accept
more or fewer inputs when you enclose the OR expression in parentheses ["("
and ")"]. If no other expressions follow the OR expression on the line, you do
not need to type the closing right parenthesis [")"].
Examples:
?or "TRUE "TRUE
TRUE
?or "TRUE "FALSE
TRUE
?or "FALSE "FALSE
FALSE
?(or "FALSE "FALSE "FALSE "TRUE
TRUE
?to weather
>print [What is the temperature today?]
>make "answer readquote
>if or (:answer < 50) (:answer > 80)
> [print [Hmm, sounds uncomfortable!]]
> [print [Sounds nice!]]
>end
weather defined
?weather
What is the temperature today?
92
Hmm, sounds uncomfortable!
?weather
What is the temperature today?
78
Sounds nice!
.out
----
Action:
Sends number to I/O port.
Syntax:
.out port_n n
Explanation:
Assigns the input number (a byte value) to the specified I/O port. Port
numbers range from 0 through 65535. THIS PRIMITIVE SHOULD BE USED WITH
CAUTION!
Examples:
?.out 10 33
output op
---------
Action:
Makes the input object the output of the procedure.
Syntax:
output object
op object
Explanation:
OUTPUT makes the input object the output of your procedure. Therefore, OUTPUT
is valid only within a procedure. As soon as your procedure outputs an object,
control returns to calling procedure or toplevel.
Examples:
?to Aurora
>output [Briar Rose]
>end
Aurora defined
?print sentence [Sleeping Beauty's name is] Aurora
Sleeping Beauty's name is Briar Rose
?to vowelp :object
>output memberp :object [a e i o u]
>end
vowelp defined
?vowelp "r
FALSE
?vowelp "e
TRUE
?to coin
>output first shuffle [heads tails]
>end
coin defined
?repeat 3 [show coin]
heads
heads
tails
?to add.up :list
>if emptyp :list
> [output 0]
>output (add.up butfirst :list) + (first :list)
>end
add.up defined
?add.up [7 6 -2]
11
package
-------
Action:
Puts the input-named objects into the input-named package.
Syntax:
package pkgname name | name list
Explanation:
PACKAGE puts the input-named procedures and variables into the package
identified by the input package name. If the package does not exist, PACKAGE
creates it. If the package already exists, PACKAGE adds the input-named
objects to the package. You can enter either a single procedure or variable
name, or a list of procedure and variable names as the second input to
PACKAGE.
A procedure or variable can be in only one package at a time, but it is easy
to move an object from one package to another. A procedure or variable resides
in the package to which it was most recently assigned with a PACKAGE command.
PACKAGE works by adding to or changing properties in the property lists of the
named objects. PACKAGE adds the .PKG property to the package name's property
list, and the .PAK property to the property list of each input-named object.
Examples:
These examples assume you have the following in your workspace: six procedures
named DRAW, CIRCLE, SQUARE, TRIANGLE, ADDUP, and GROW; and five variables
named SIZE, BIG, SMALL, MEDIUM, and PENSTATE.
?pots
to draw
to circle :size
to square :size
to triangle :size
to add.up :list
to grow :size
?package "shapes [circle square triangle]
?pons
size is 100
big is 80
small is 20
medium is 40
penstate is [pd 1]
?package "sizes [big medium small]
?popkg
sizes
"medium (VAL)
"small (VAL)
"big (VAL)
shapes
to square :size
to triangle :size
to circle :size
?package "sizes "grow
?popkg
sizes
to grow :size
"medium (VAL)
"small (VAL)
"big (VAL)
shapes
to square :size
to triangle :size
to circle :size
paddle (Not a primitive)
------
Action:
Outputs a number that represents a paddle (joystick) input coordinate.
Syntax:
paddle n
Explanation:
You can use PADDLE to read the position of a paddle or joystick. Dr. Logo
supports up to two paddles or joysticks. If your IBM Personal Computer does
not have a paddle or joystick when Dr. Logo encounters a PADDLE command,
PADDLE returns 0. The range of values that paddle outputs depends on your
particular paddle or joystick.
The number you input to PADDLE tells Dr. Logo which coordinate you want PADDLE
to output. The input number must be in the range 0 to 3:
PADDLE 0 outputs the X-coordinate of paddle1
PADDLE 1 outputs the Y-coordinate of paddle1
PADDLE 2 outputs the X-coordinate of paddle2
PADDLE 3 outputs the Y-coordinate of paddle2
where PADDLE1 is the first paddle or joystick, and PADDLE2 is the second
paddle or joystick.
Examples:
DRAW allows the user to guide the turtle with the joystick. DRAW contains
calculations that convert X and Y coordinates returned by PADDLE into turtle
coordinates. PADDLE returns a 190-number range for the X-coordinate of this
particular joystick, and a 144-number range for the Y-coordinate of this
particular joystick. AMOUNT smooths the turtle's response to the joystick's
commands.
?to draw
>repeat 10000
> [make "xin paddle 0
> make "yin paddle 1
> make "xin int ((:xin * (300 / 190)) - 150)
> make "yin int ((:yin * (-200 / 144)) + 90)
> setheading towards list :xin :yin
> forward (amount * 0.1)
> if buttonp 0 [stop]
> if buttonp 1 [clean]
>end
draw defined
?to amount
>output int sqrt
> ((abs :xin) * (abs :xin) +
> ((abs :yin) * (abs :yin)))
>end
amount defined
?draw
pal (= PALette of colors)
---
Action:
Output a list of RGB values for a given pen index.
Syntax:
pal pen_index
Explanation:
Outputs a list of color components for the given pen_index. The range of
values for pen_index are 0 through 255. Item 1 of the list represents the Red
component of the color, item 2 represents the Green component, and item 3 is
for Blue. The range of values for the RGB values are 0 through 63.
Examples:
?pal 0
[0 0 0] ; Black
?pal 1
[0 0 42] ; Blue
?pal 2
[0 42 0] ; Green
?pal 3
[0 42 42] ; Cyan
?pal 4
[42 0 0] ; Red
?pal 5
[42 0 42] ; Magenta
?pal 6
[42 21 0] ; "Yellow"
?pal 7
[42 42 42] ; "White"
(ROCHE> To get the true colors, use 63. By default, Dr. Logo uses 42 for
normal intensity, and 21 for half intensity. To get true Yellow, use [63 63
0]. And [63 63 63] for White. Normally, once you have Red, Green, and Blue,
you are served. Personally, I prefer a Black background. You can use White or
Yellow for the turtle.)
pause
-----
Action:
Suspends the execution of the current procedure, to allow interaction with the
interpreter or editor.
Syntax:
pause
Explanation:
PAUSE suspends the execution of the current procedure, and lets you interact
with the interpreter or editor. Therefore, the PAUSE command is valid only
within a procedure. When Dr. Logo encounters a PAUSE command, it suspends
execution of the procedure, displays a "Pausing..." message, and allows you to
interact with the interpreter. To end the PAUSE, enter CO.
PAUSE is one of the three ways you can cause a pause in the execution of your
procedure.
A PAUSE expression causes a "breakpoint" in your procedure. For example, you
can insert a PAUSE command just before an expression that has been regularly
causing an error. When you execute the procedure, Dr. Logo will pause before
the problem expression. During the pause, you can experiment by entering
variations of the problem expression, and examine or change local variables
whose values will be discarded when the procedure finishes executing. Enter CO
to end the PAUSE and continue execution.
Examples:
?make "size 100
?to nautilus :size
>if (remainder :size 5) = 0
> [pause]
>repeat 36
> [forward :size right 10]
>right 15
>nautilus :size + 0.5
>end
nautilus defined
?clearscreen right 180
?nautilus 1
Pausing... in nautilus: [if [remainder :size 5) = 0 [pause]]
nautilus ?:size
5
nautilus ?co
Pausing... in nautilus: [if [remainder :size 5) = 0 [pause]]
nautilus ?:size
5.5
nautilus ?co
Pausing... in nautilus: [if [remainder :size 5) = 0 [pause]]
nautilus ?:size
10
nautilus ?stop
?:size
100
pendown pd
----------
Action:
Puts the turtle's pen down; the turtle resumes drawing.
Syntax:
pendown
pd
Explanation:
PENDOWN makes the turtle put its pen down and begin drawing in the current pen
color. The pen is down when you start Dr. Logo. Use PENDOWN to resume normal
drawing after a PENUP, PENERASE, or PENREVERSE.
Examples:
?to pen
>output list item 4 turtlefacts item 5 turtlefacts
>end
pen defined
?pen
[pu 2]
?pendown pen
[pd 2]
?to halo :size
>repeat 36
> [forward :size * 0.5 penup
> forward :size * 0.1 pendown
> forward :size * 0.2 penup
> forward :size * 0.1 pendown
> forward :size * 0.1 penup
> back :size right 10 pendown]
>ht
>end
halo defined
?halo 100
penerase pe
-----------
Action:
Puts the turtle's eraser down; turtle erases drawn lines.
Syntax:
penerase
pe
Explanation:
PENERASE makes the turtle put its eraser down. With the eraser down, the
turtle erases any drawn lines it passes over. To lift the eraser, use PENUP or
PENDOWN.
Examples:
?to pen
>output list item 4 turtlefacts item 5 turtlefacts
>end
pen defined
?pen
[pd 2]
?penerase pen
[pe 2]
?to move.triangle
>clearscreen
>hideturtle
>repeat 36
> [triangle40 penerase triangle40 pendown setpc 2 right 10]
>end
move.triangle defined
?to triangle40
>repeat 3
> [forward 40 right 120]
>end
triangle40 defined
?move.triangle
penreverse px
-------------
Action:
Makes turtle erase where lines are drawn, and draw where there are no lines.
Syntax:
penreverse
px
Explanation:
PENREVERSE makes the turtle draw where there are no lines, and erase where
there are lines. To stop using the reversing pen, enter PENUP or PENDOWN.
Examples:
?to pen
>output list item 4 turtlefacts item 5 turtlefacts
>end
pen defined
?pen
[pd 2]
?penreverse pen
[px 2]
?to moving.triangle
>clearscreen
>hideturtle
>penreverse
>repeat 26
> [triangle40 triangle40 right 10]
>end
moving.triangle defined
?to triangle40
>repeat 3
> [forward 40 right 120]
>end
triangle40 defined
?moving.triangle
penup pu
--------
Action:
Picks the turtle's pen up; the turtle stops drawing.
Syntax:
penup
pu
Explanation:
PENUP makes the turtle pick its pen up and stop leaving a trace of its path.
Use PENDOWN to resume normal drawing after a PENUP command.
Examples:
?to pen
>output list item 4 turtlefacts item 5 turtlefacts
>end
pen defined
?pen
[pd 2]
?penup pen
[pu 2]
?to halo :size
>repeat 36
> [forward :size * 0.5 penup
> forward :size * 0.1 pendown
> forward :size * 0.2 penup
> forward :size * 0.1 pendown
> forward :size * 0.1 penup
> back :size right 10 pendown]
>ht
>end
halo defined
?pendown halo 100
pi
--
Action:
Outputs the value of pi.
Syntax:
pi
Explanation:
PI outputs the value of pi: 3.14159265358979.
Examples:
?(print char 227 "= pi ; Code Page 850
π = 3.14159265358979
?to find.radius :n
>repeat 180
> [forward :n left 2]
>make "radius (180 * :n) / (2 * pi)
>(print [Radius =] :radius
>left 90 forward radius
>end
find.radius defined
?penup sety -90 pendown right 90
?find.radius
radius = 85.9436692696235
piece
-----
Action:
Outputs an object that contains the specified elements of the input object.
Syntax:
piece n n object
Explanation:
PIECE outputs an object made up of the elements of the input object. The two
input numbers specify which elements are to be included in the output object.
The range you specify is inclusive; for example, when you specify PIECE 3 8,
the third and eight elements are included in the output object.
Examples:
?piece 4 7 "Kensington
sing
?piece 2 4 [Nana John Michael Wendy Tinkerbell]
[John Michael Wendy]
?to last.part :name
>if memberp ". :name
> [make "readlist where]
> [(print :name [in wrong format.]) stop]
>make "r2 count :name
>output piece (:r1 + 1) :r2 :name
>end
last.part defined
?last.part "Peter.Pan
Pan
pkgall (= PacKaGe ALL)
------
Action:
Puts all procedures and variables not in packages into the specified package.
Syntax:
pkgall pkgname
Explanation:
PKGALL assigns all procedures and variables not already in packages to the
input-named package. If the package does not exist, PKGALL creates it. If the
package does exist, PKGALL adds the unpackaged procedures and variables to the
existing package.
Examples:
These examples assume that you have the following in your workspace: a buried
package named SHAPES that contains three procedures named CIRCLE, SQUARE, and
TRIANGLE; a buried package named SIZES that contains three variables named
BIG, MEDIUM, and SMALL; and three unpackaged objects: a variable named
PEN.STATE and two procedures named DRAW and GROW.
?popkg
shapes is buried
to square :size
to circle :size
to triangle :size
sizes is buried
"medium (VAL)
"small (VAL)
"big (VAL)
?pots
to grow :size
to draw
?pons
pen.state is [pd 2]
?pkgall "other
?popkg
other
to grow :size
to draw
"pen.state (VAL)
shapes is buried
to square :size
to circle :size
to triangle :size
sizes is buried
"medium (VAL)
"small (VAL)
"big (VAL)
plist (= Property LIST)
-----
Action:
Outputs the property list of the input-named object.
Syntax:
plist name
Explanation:
PLIST outputs the property list of the input-named object. Section 5,
"Property Lists, Workspace, and Disks", describes property lists, and defines
the properties Dr. Logo gives to objects in the workspace. To understand the
examples below, remember that a property list is made up of property pairs.
The first element of the pair is the property; the second, its value. Dr. Logo
gives defined properties the .DEF property, and defined variables the .APV
property.
Examples:
These examples assume you have, in your workspace, a procedure named TRIANGLE
and a variable named STAR.
?plist "triangle
[.DEF [[size] [repeat 3 [forward :size right 120]]]]
?plist "star
[.APV evening]
?to remove :name
>if emptyp plist :name
> [stop]
>make "prop first plist :name
>run (sentence "remprop "quote :name "quote :prop)
>remove :name
>end
remove defined
?make "bird "blue
?:bird
blue
?remove "bird
?:bird
bird has no value
po (= Print Out)
--
Action:
Displays the definition(s) of the specified procedure(s).
Syntax:
po procname | procname_list
Explanation:
PO displays the definition of a procedure, or the definitions of a list of
procedures. When you do not have your procedures grouped in an appropriate
package and cannot use POPS, you can input a list of procedure names to PO to
display the definitions of a group of procedures.
Examples:
?to triangle :size
>repeat 3
> [forward :size right 120]
>end
triangle defined
?to square :size
>repeat 4
> [forward :size right 90]
>end
square defined
?po "square
to square :size
repeat 4
[forward :size right 90]
end
?po [triangle square]
to triangle :size
repeat 3
[forward :size right 120]
end
to square :size
repeat 4
[forward :size right 90]
end
poall (= Print Out ALL)
-----
Action:
Displays the definitions of all procedures and variables in the workspace or
input-named package(s).
Syntax:
poall < pkgname | pkgname_list >
Explanation:
Without an input, POALL displays the definitions of all procedures and
variables in the workspace. POALL with a package name as input displays the
definitions of all procedures and variables in the input-named package. You
can input a list of package names to POALL to display the contents of several
packages.
Examples:
These examples assume you have two packages named SHAPES and SIZES in your
workspace.
?poall
POALL displays the definitions of all procedures and variables in the
workspace.
?poall "shapes
POALL displays the definitions of all procedures and variables in the package
named SHAPES.
?poall [shapes sizes]
POALL displays the definitions of all procedures and variables in the packages
named SHAPES and SIZES.
pocall (= Print Out CALLed procedure)
------
Action:
Displays the names of the procedures called by the input-named procedure.
Syntax:
pocall procname
Explanation:
POCALL displays the names of the procedures called by the input-named
procedure. The name of each called procedure is indented on the line beneath
the name of the procedure that calls it. The procedure names appear in the
order in which they are called.
Examples:
?to wheel
>repeat 12
> [flag left 30]
>end
wheel defined
?to tri
>repeat 3
> [right 120 forward 25]
>end
tri defined
?to flag
>forward 50 tri back 50
>end
flag defined
?pocall "wheel
wheel
flag
tri
?to add.up :list
>if emptyp :list
> [output 0]
>output (add.up butfirst :list) + (first :list)
>end
add.up defined
?pocall "add.up
add.up :list
add.up :list
pons (= Print Out NameS)
----
Action:
Displays the names and values of all variables in the workspace or specified
package(s).
Syntax:
pons < pkgname | pkgname_list >
Explanation:
Without an input, PONS displays the names and values of all the variables
defined in the workspace. With a package name as input, PONS displays the
names and values of all the variables contained in the specified package. You
can input a list of package names to PONS to display variable names and values
from several packages.
Examples:
These examples assume you have the following in your workspace: three
variables named BIG, MEDIUM, and SMALL in a package named sizes; two variables
named BIRD and SNAKE in a package named ANIMALS; and a variable named
PENSTATE.
?to pen
>output list item 4 turtlefacts item 5 turtlefacts
>end
pen defined
make "pen.state pen
?pons
medium is 40
small is 20
big is 80
bird is blue
pen.state is [pd 2]
snake is green
?pons "sizes
medium is 40
small is 20
big is 80
?pons [sizes animals]
medium is 40
small is 20
big is 80
bird is blue
snake is green
popkg (= Print Out PacKaGe)
-----
Action:
Displays the name and contents of each package in the workspace.
Syntax:
popkg < pkgname | pkgname_list >
Explanation:
POPKG displays the name and contents of each package in the workspace. The
names of variables and procedures in the package are indented under the
package name. Variable names are quoted, and are followed by (VAL). Procedure
names are preceded by the word TO and are followed by their inputs, if any.
Object names that have properties are quoted, and are followed by (PROP).
POPKG includes the names and contents of buried packages, and indicates that
the package is buried.
POPKG accepts a package name or a list of package names as input. When you
specify a package or list of packages, POPKG displays the contents of the
specified package only.
Examples:
These examples assume you have four packages named WHEEL, SIZES, AVERAGE, and
SHAPES in your workspace.
?popkg
wheel
to wheel
to flag
to tri
sizes
"big (VAL)
"small (VAL)
"medium (VAL)
average
to add.up :list
to average :list
shapes
to circle :size
to triangle :size
to square :size
?bury "average
?popkg
wheel
to wheel
to flag
to tri
sizes
"big (VAL)
"small (VAL)
"medium (VAL)
average is buried
to add.up :list
to average :list
shapes
to circle :size
to triangle :size
to square :size
pops (= Print Out ProcedureS)
----
Action:
Displays the names and definitions of all procedures in the workspace or
specified package(s).
Syntax:
pops < pkgname | pkgname_list >
Explanation:
Without an input, POPS displays the names and definitions of all the
procedures defined in the workspace. With a package name as input, POPS
displays the names and definitions of all the procedures contained in the
specified package. You can input a list of package names to POPS to display
procedure names and definitions from several packages.
Examples:
These examples assume you have the following in your workspace: three
procedures named WHEEL, FLAG, and TRI in a package named WHEEL; two procedures
named AVERAGE and ADDUP in a package named average; and a procedure named
SQUARE.
?pops
to wheel
repeat 12
[flag left 30]
end
to square :size
repeat 4
[forward :size right 90]
end
to tri
repeat 3
[right 120 forward 25]
end
to flag
forward 50 tri back 50
end
to add.up :list
if emptyp :list
[output 0]
output (add.up butfirst :list) + (first :list)
end
to average :list
output (add.up :list) / (count :list)
end
?pops "wheel
to wheel
repeat 12
[flag left 30]
end
to tri
repeat 3
[right 120 forward 25]
end
to flag
forward 50 tri back 50
end
?pops [wheel average]
to wheel
repeat 12
[flag left 30]
end
to tri
repeat 3
[right 120 forward 25]
end
to flag
forward 50 tri back 50
end
to add.up :list
if emptyp :list
[output 0]
output (add.up butfirst :list) + (first :list)
end
to average :list
output (add.up :list) / (count :list)
end
poref (= Print Out REFerenced procedures)
-----
Action:
Displays the names of the procedures that call the input-named procedure(s).
Syntax:
poref procname | procname_list
Explanation:
POREF displays the names of any procedures that call the input-named
procedure. You can use POREF to check that other procedures will be affected
when you change the input-named procedure.
Examples:
?to wheel
>repeat 12
> [flag left 30]
>end
wheel defined
?to tri
>repeat 3
> [right 120 forward 25]
>end
tri defined
?to flag
>forward 50 tri back 50
>end
flag defined
?poref "tri
to flag
?poref "flag
to wheel
?to add.up :list
>if emptyp :list
> [output 0]
>output (add.up butfirst :list) + (first :list)
>end
add.up defined
?to average :list
>output (add.up :list) / (count :list)
>end
average defined
?poref "add.up
to average :list
to add.up :list
pos
---
Action:
Outputs a list that contains the coordinates of the turtle's current position.
Syntax:
pos
Explanation:
POS outputs a two-element list that identifies the turtle's current position.
The format of the list is suitable for input to SETPOS. When the turtle is
plotting on screen, the first element of the list is the X-coordinate in the
range -150 to +149, and the second element is the Y-coordinate in the range
-99 to +100. When the turtle is off the screen, either the X or Y coordinate
or both will be greater than the visible range.
Examples:
?clearscreen pos
[0 0]
?to save.place
>make "place pos
>end
save.place defined
?to return
>setpos :place
>end
return defined
?setpos list (random 150) (random 100)
?pos
[90 22]
?save.place
?setpos list (random 150) (random 100)
?pos
[55 73]
?return
?to find.center :n
>repeat 180
> [forward :n left 2]
>make "radius (180 * :n) (2 * pi)
>left 90 forward :radius
>show pos
>end
find.center defined
?penup back 80 right 90 back 90 pd
?find.center 2
[-89.9891 -22.6934]
potl (= Print Out Top Level procedures)
----
Action:
Displays the names of the procedures that are not called by any other
procedures in the workspace.
Syntax:
potl
Explanation:
POTL displays the names of toplevel procedures, procedures that are not called
by any other procedures in the workspace, and are executed only by direct
command at the interpreter's ? prompt. Use POTL to discover which procedures
do not affect other procedures, or which procedure names are good candidates
for subsequent POCALL command.
Examples:
?to wheel
>repeat 12
> [flag left 30]
>end
wheel defined
?to tri
>repeat 3
> [right 120 forward 25]
>end
tri defined
?to flag
>forward 50 tri back 50
>end
flag defined
?to add.up :list
>if emptyp :list
> [output 0]
>output (add.up butfirst :list) + (first :list)
>end
add.up defined
?to average :list
>output (add.up :list) / (count :list)
>end
average defined
?potl
to wheel
to average :list
pots (= Print Out TitleS)
----
Action:
Displays the names and inputs of all procedures in the workspace or specified
package(s).
Syntax:
pots < pkgname | pkgname_list >
Explanation:
Without an input, POTS displays the names and inputs of all the unburied
procedures in the workspace. With a package name as input, POTS prints the
names and inputs of all the procedures in the package, even if the package is
buried. You can input a list of package names to POTS to display the names and
inputs of procedure in several packages.
Examples:
This example assumes you have the following in your workspace: three
procedures named WHEEL, FLAG, and TRI in a package named WHEEL; two procedures
named average and ADDUP in a package named AVERAGE; and three procedures named
SQUARE, CIRCLE, and TRIANGLE.
?pots
to wheel
to tri
to square :size
to flag
to add.up :list
to average :list
to circle :size
to triangle :size
?pots "average
to add.up :list
to average :list
?pots [average wheel]
to wheel
to flag
to tri
to add.up :list
to average :list
pprop (= Put PROperty Pair)
-----
Action:
Puts the input property pair into the input-named object's property list.
Syntax:
pprop name prop object
Explanation:
PPROP puts a property pair into the input-named object's property list. PPROP
requires three inputs: the name of the object to which the property is to be
added, the name of the property, and the object that is to be the value of the
property. PPROP makes the input property pair the first pair in the input-
named object's property list.
You can use PPROP to add standard Dr. Logo system properties to a property
list. For example, if you use PPROP to add the .APV property to an object's
property list, you create a variable the same as if you had used NAME or MAKE.
You must use PPROP to add your own special properties to a property list.
However, the erasing commands (ERASE, ERN, ERALL, ERPS, and ERNS) remove only
standard Dr. Logo system properties from property lists. This means that, if
you have assigned a non-standard property to an object's property list, that
object will still be in the workspace after an ERALL commmand. Use REMPROP to
remove your special properties from a property list.
Examples:
?pprop "dungeonmaster ".APV "Scott
?:dungeonmaster
Scott
?to make.character :name
>make "abilities [strength intelligence wisdom dexterity constitution
charisma]
>make "other [class hitpoints armorclass alignment level experience
goldpieces]
>assign :abilities
>assign :other
>(print [You have given] :name [the following characteristics:]
>print plist :name
>end
make.character defined
?to assign :list
>if emptyp :list
> [stop]
>print word first :list "?
>make "value readlist
>pprop :name first :list :value
>assign butfirst :list
>end
assign defined
?make.character "Borg
Strength?
17
Intelligence?
8
(...)
You have given Borg the following characteristics: goldpieces [10] experience
[0] level [1] alignment [lawful] armorclass [3] hitpoints [6] class [fighter]
charisma [6] constitution [15] dexterity [7] wisdom [10] intelligence [8]
strength [17]
pps (= Property PairS)
---
Action:
Displays the non-system property pairs of all objects in the workspace or
specified packages.
Syntax:
pps < pkgname | pkgname_list >
Explanation:
Without an input, PPS prints out the special property pairs you have assigned
with a PPROP command to any object in the workspace. If you have not assigned
any special properties, PPS prints nothing. With a package name as input, pps
prints the special property pairs from the specified package, even if the
package is buried. You can input a list of package names to PPS to display the
names and inputs of procedures in several packages.
Examples:
?pprop "Kathy "extension 82
?pps
Kathy's extension is 82
prec
----
Action:
Outputs the number of significant digits.
Syntax:
prec
Explanation:
Outputs the number of significant digits displayed in an output number.
Examples:
?prec
6
primitivep (= PRIMITIVE Predicate)
----------
Action:
Outputs TRUE if the input object is a primitive name.
Syntax:
primitivep object
Explanation:
PRIMITIVEP outputs TRUE if the input object is a primitive name; otherwise,
PRIMITIVEP outputs FALSE.
Examples:
?primitivep "phone
FALSE
?primitivep "home
TRUE
print pr
--------
Action:
Displays the input object(s) on the text screen.
Syntax:
print object (...)
pr object (...)
Explanation:
PRINT displays the input object on the screen, followed by a Carriage Return.
PRINT removes the outer square brackets ("[" and "]") from an input list.
Compare print with TYPE and SHOW. You can input any number of objects by
preceding them with a left parenthesis ["("]. When preceded by a left
parenthesis, PRINT displays all its inputs on the same line, and follows only
the last input with a Carriage Return.
Examples:
?print [This is a message.]
This is a message.
?make "variable "silly
?(print [This is a] :variable "message.)
This is a silly message.
proclist (= PROCedure LIST)
--------
Action:
Outputs a list that contains the names of all defined procedures.
Syntax:
proclist
Explanation:
PROCLIST outputs a list that contains the names of all procedures currently
defined in the workspace.
Examples:
This example assumes you have the following procedures in your workspace:
WHEEL, FLAG, TRI, ADDUP, and AVERAGE.
?pots
to wheel
to flag
to tri
to add.up
to average
?proclist
[wheel flag tri add.up average]
?package "current proclist
?popkg
current
to wheel
to flag
to tri
to add.up :list
to average :list
product *
---------
Action:
Outputs the product of the input numbers.
Syntax:
product n n (...)
* n n (...)
Explanation:
PRODUCT outputs the product of the input numbers. PRODUCT is equivalent to the
* arithmetic operator.
Without punctuation, PRODUCT requires and accepts two input objects. PRODUCT
can accept more or fewer inputs when you enclose the PRODUCT expression in
parentheses ["(" and ")"]. If no other expressions follow the PRODUCT
expression on the line, you do not need to type the closing right parenthesis
[")"].
Examples:
?product 7 6
42
?* 7 6
42
?(product 2 pi 5)
31.4159265358979
?(* 2 pi 5
31.4159265358979
?(product 7)
7
?(* 7)
7
?to cube :n
>output (product :n :n :n)
>end
cube defined
?cube 3
27
quotient
--------
Action:
Outputs the quotient of the two input numbers.
Syntax:
quotient n n
Explanation:
QUOTIENT outputs the number that results when the first input number is
divided by the second. QUOTIENT truncates any input decimal number to an
integer. Unlike the / operator, if the result ends in a decimal fraction,
QUOTIENT truncates the result to an integer.
Examples:
?quotient 10 4
2
?10/4
2.5
?quotient -10 5
-2
?quotient 5 0
Can't divide by zero
?quotient 5 .9
Can't divide by zero
radians
-------
Action:
Outputs the number of radians in the input number of degrees.
Syntax:
radians degrees_n
Explanation:
RADIANS outputs the number of radians in the input number of degrees, where
degrees = radians * (180 / pi).
Examples:
?radians 90
1.5707963267949
?radians 180
3.14159265358979
?pi
3.14159265358979
?radians 450
7.85398163397449
random
------
Action:
Outputs a random non-negative integer less than the input number.
Syntax:
random n
Explanation:
RANDOM outputs a random non-negative integer less than the input number. This
means random might output any integer from zero to one less than the input
number. For example, random 2 will output either 0 or 1.
Examples:
?random 10
4
?repeat 20 [(type random 10 char 9)]
3 0 2 3 1 4 6 4 4 7 9 4 5 1 8 2
?to draw.spinner :n
>if (:n > 330)
> [stop]
>penup right 15 forward 25
>turtletext (word (int (:n / 36)))
>back 25 right 21 forward 25 pendown forward 5 penup back 30
>draw.spinner :n + 36
>end
draw.spinner defined
?to spin
>repeat 72 * random 6
> [right 5]
>repeat random 45
> [right 5]
>print int (heading / 36)
>end
spin defined
?draw.spinner 0
?spin
1
readchar rc
-----------
Action:
Outputs the first character typed at the keyboard.
Syntax:
readchar
rc
Explanation:
READCHAR outputs the first character typed at the keyboard. READCHAR can
output any character you can type, including control characters, except Ctrl-
G. Ctrl-G stops execution and returns to toplevel.
During a procedure's execution, READCHAR does not move the cursor or display
the input character on the screen. If no character is waiting to be read,
REACHAR waits until you type something. If something is waiting to be read,
READCHAR immediately outputs the first character in the keyboard buffer. The
description of KEYP tells how to check if a character is waiting to be read.
Examples:
?readchar
z
?to quiz
>print [Do you know any Martians?]
>if lowercase readchar = "y
> [print [Takes one to know one!]]
> [print [Me either!]]
>end
quiz defined
?quiz
Do you know any Martians? y
Takes one to know one!
?to poly.cycle :n
>(print [Press any key to draw a] :n [sided figure.])
>sink readchar cs
>repeat :n
> [forward 40 right (360 / :n)]
>if :n > 8
> [stop]
>poly.cycle :n + 1
>end
poly.cycle defined
?to sink :object
>end
sink defined
?poly.cycle 3
Press any key to draw a 3 sided figure.
Press any key to draw a 4 sided figure.
Press any key to draw a 5 sided figure.
Press any key to draw a 6 sided figure.
Press any key to draw a 7 sided figure.
Press any key to draw a 8 sided figure.
Press any key to draw a 9 sided figure.
readeofp (= READ End-Of-File Predicate)
--------
Action:
Outputs TRUE if end of data file reached.
Syntax:
readeofp
Explanation:
Outputs TRUE if the current data file is at the end; otherwise, outputs FALSE.
You must use OPEN and SETREAD before you use READEOFP.
(ROCHE> There is a system message, saying that "Only 4 files can be open".)
Examples:
?open "telnos
?setread "telnos
?readeopf
FALSE
reader
------
Action:
Outputs current open file name.
Syntax:
reader
Explanation:
Outputs the current file name that is open for reading.
(ROCHE> There is a system message, saying that "Only 4 files can be open".)
Examples:
?reader
[A:BOOKLIST.DAT]
readlist rl
-----------
Action:
Outputs a list that contains a line typed at the keyboard.
Syntax:
readlist
rl
Explanation:
READLIST outputs a list that contains a line typed at the keyboard. READLIST
always displays the input line on the screen before outputting the list.
READLIST can read a line only after you press the Carriage Return (Enter) key.
If no line is waiting to be read, READLIST waits for something to be typed. If
a line is waiting to be read, READLIST outputs the line immediately. The
description of KEYP tells how to check if something is waiting to be read.
Examples:
?readlist
yippee ti yi yo
[yippee ti yi yo]
?repeat 5 readlist
forward 40 right 72
?to interpret
>print [What next, boss?]
>run readlist
>interpret
>end
interpret defined
?to my.message
>catch "error [interpret]
>(print "Oops, first butfirst error [!!!])
>print [What do you want to do about that?]
>run readlist
>my.message
>end
my.message defined
?my.message
What next, boss?
fence
What next, boss?
forward 200
Oops, Turtle out of bounds !!!
What do you want to do about that?
back 100
What next, boss?
to quit
Oops, I don't know to to !!!
What do you want to do about that?
stop
readquote rq
------------
Action:
Outputs a word that contains a line typed at the keyboard.
Syntax:
readquote
rq
Explanation:
READQUOTE outputs a word that contains a line typed at the keyboard. READQUOTE
always displays the input line on the screen. READQUOTE can read a line only
if the line is ended with a Carriage Return (Enter) keystroke.
If the line contains words separated by spaces, READQUOTE inserts backslant
characters ("\") in front of the spaces, so that the spaces are treated as
literal characters. This makes the line one word. You can see the backslant
characters if you load an object created with READQUOTE into the editor.
When no line is waiting to be read, READQUOTE waits until something is typed.
If a line is waiting to be read, READQUOTE outputs the line immediately. You
can use keyp to see if a line is waiting to be read.
Examples:
?readquote
I don't think we are in Kansas anymore...
I don't think we are in Kansas anymore...
recycle
-------
Action:
Reorganizes the workspace, to free as many nodes as possible.
Syntax:
recycle
Explanation:
RECYCLE reorganizes and cleans up the workspace, freeing as many nodes as
possible. After RECYCLE, NODES can tell you how much of the workspace is
filled with procedures, variables, and other defined objects.
RECYCLE works by calling the garbage collector. Dr. Logo automatically calls
the garbage collector when it is needed. However, if the timing of one of your
procedures is critical, you can run RECYCLE before executing the procedure, to
ensure that your procedure will not be interrupted by an automatic garbage
collection. Section 5, "Property Lists, Workspace, and Disks", describes the
garbage collector, and how it reorganizes and cleans up the workspace.
Examples:
?nodes
55702
?recycle
?nodes
59524
?to spi :side :angle :inc
>forward :side
>right :angle
>spi :side + :inc :angle :inc
>end
spi defined
?spi 10 100 2
I'm out of space in spi: spi :side + :inc :angle :inc
!recycle
?nodes
55380
redefp (= REDEFine Predicate) (Not a primitive)
------
Not a primitive, but a system variable.
When REDEFP is TRUE, primitives can be redefined. But the new definition will
take all the characteristics of the primitive; it cannot be printed out or
edited.
remainder
---------
Action:
Outputs the integer remainder obtained when the first input number is divided
by the second.
Syntax:
remainder n n
Explanation:
REMAINDER outputs the integer that is the remainder obtained when the first
input number is divided by the second input number.
Examples:
?remainder 7 2
1
?to evenp :n
>if 0 = remainder :n 2
> [output "TRUE]
> [output "FALSE]
>end
evenp defined
?evenp 11
FALSE
?evenp 6
TRUE
remprop (= REMove PROPerty)
-------
Action:
Removes the specified property from the input-named object's property list.
Syntax:
remprop name prop
Explanation:
REMPROP removes the specified property and its value from the input-named
object's property list. You may use REMPROP to remove any non-system
properties you put in an object's property list with PPROP. You must remove
all properties from an object's property list to completely remove the object
from the workspace.
Examples:
?pons
horse1 is Tinderbox
horse2 is Muffy
?plist "horse1
[color bay .APV Tinderbox]
?ern "horse1
?plist "horse1
[color bay]
?remprop "horse1 "color
?plist "horse1
[]
?plist "horse2
[color [liver chestnut] class [hunter jumper] .APV Muffy]
?to remove :name
>if emptyp plist :name
> [stop]
>make "prop first plist :name
>run (sentence "remprop "quote :name "quote :prop)
>remove :name
>end
remove defined
?remove "horse2
?plist "horse2
[]
repeat
------
Action:
Executes the input instruction list the input number of times.
Syntax:
repeat n instr_list
Explanation:
REPEAT executes the input instruction list the input number of times. The
input number must be positive. If the input number is not an integer, REPEAT
truncates it to an integer.
If you want a procedure to execute continuously, such as the DRAW procedure
shown in the description of PADDLE, you can use REPEAT 1/0 instead of a
recursive call. This minimizes interruptions from the garbage collector. We
recommend that you use a recursive call as you write your procedure, so that
you can take advantage of Dr. Logo's line-by-line debugging facilities. Then,
when your procedure is working correctly, remove the recursive call and
enclose the entire procedure definition within a single line: REPEAT 1/0 with
a lengthy input instruction list.
Examples:
?repeat 100 [print [I will not chew gum in class.]
I will not chew gum in class.
I will not chew gum in class.
I will not chew gum in class.
I will not chew gum in class.
I will not chew gum in class.
I will not chew gum in class.
(...)
?make :sides 3
?repeat :sides [forward 40 right (360 / :sides)]
?to spi :side :angle :inc
>forward :side
>right :angle
>spi :side + :inc :angle :inc
>end
spi defined
?spi 10 100 2
I'm out of space in spi: spi :side + :inc :angle :inc
!recycle
?to rep.spi :side :angle :inc
>repeat 200
> [forward :side
> right :angle
> make "side :side + :inc]
>end
rep.spi defined
?rep.spi 10 100 2
.replace
--------
Action:
Replaces the specified item of the list with the object.
Syntax:
.replace item_n varlist object
Explanation:
Replaces the specified item of the list with the object. THIS PRIMITIVE SHOULD
BE USED WITH CAUTION!
Examples:
?make "varlist [A B C D E F]
?.replace 4 :varlist [1 2 3]
?:varlist
[A B C [1 2 3] E F]
.reptail
--------
Action:
Replaces all items following the specified item in the list with the object.
Syntax:
.reptail item_n varlist object
Explanation:
Replaces all items following the specified item in the list with the object.
THIS PRIMITIVE SHOULD BE USED WITH CAUTION!
Examples:
?make "varlist [A B C D E F]
?.reptail 4 :varlist [1 2 3]
?:varlist
[A B C D [1 2 3]]
rerandom
--------
Action:
Makes a subsequent RANDOM expression reproduce the same random sequence.
Syntax:
rerandom
Explanation:
RERANDOM makes a subsequent RANDOM expression reproduce the same random
sequence.
Examples:
?repeat 10 [(type random 10 char 9)] print []
2 3 7 5 3 2 0 4 2 6
?repeat 10 [(type random 10 char 9)] print []
8 9 9 1 0 6 1 3 5 1
?rerandom
?repeat 10 [(type random 10 char 9)] print []
6 2 9 0 3 1 6 2 3 7
?rerandom
?repeat 10 [(type random 10 char 9)] print []
6 2 9 0 3 1 6 2 3 7
right rt
--------
Action:
Rotates the turtle the input number of degrees to the right.
Syntax:
right degrees_n
rt degrees_n
Explanation:
RIGHT rotates the turtle the input number of degrees to the right. Usually,
you input a number of degrees between 0 and 359. If the input number is
greater than 359, the turtle appears to move the input number minus 360
degrees to the right. If you input a negative number to right, the turtle
turns to the left.
Examples:
?repeat 36 [right 10]
?repeat 36 [right -10]
?to around.R :s
>repeat 360
> [forward :s right 10 make "s :s + .01]
>end
around.R defined
?around.R 2
round
-----
Action:
Outputs the input number rounded off to the nearest integer.
Syntax:
round n
Explanation:
ROUND outputs the input number rounded off to the nearest integer. If the
fractional portion of the input number is 0.5 or greater, ROUND rounds up to
the next integer. To truncate a decimal number to an integer, use INT.
Examples:
?round 3.333333
3
?int 28753/12
2149
?round -75.482
-75
?round 0.5
1
run
---
Action:
Executes the input instruction list.
Syntax:
run instr_list
Explanation:
RUN executes the input instruction list. If the input object outputs an
object, RUN outputs that object. You can use LIST or SENTENCE to assemble an
instruction list for run to execute.
Examples:
?run [print [tricolor]]
tricolor
?run [equalp 0 9]
FALSE
?to use :what
>if memberp lowercase :what [green red yellow]
> [make "colornumber where
> make "state "pd]
>if "eraser = lowercase :what
> [make "state "pe]
>run (sentence "setpen "list "quote :state "quote :colornumber)
>end
use defined
?use "green forward 60 right 120
?use "red forward 60 right 120
?use "yellow forward 60 right 120
?to while :condition :instr_list
>if "TRUE = run :condition
> [run :instr_list]
> [stop]
>while :condition :instr_list
>end
while defined
?make "side 5
?while [:side < 50] [forward :side right 60 make "side :side + 2]
save
----
Action:
Writes the contents of the workspace or specified package(s) to the input-
named disk file.
Syntax:
save fname < pkgname | pkgname_list >
Explanation:
SAVE writes the contents of the workspace or specified package(s) to the
input-named disk file. If there is already a file with the specified name on
the disk, SAVE displays the message "File already exists." Choose another name
for the new file, delete the old file with ERASEFILE, or rename it with
CHANGEF. If there is no file with the specified name on the disk, SAVE creates
one with the file type LOG. File names in the disk's directory cannot be
longer than eight characters. So, if you specify a file name with more than
eight characters, SAVE truncates the file name to eight characters.
If you do not specify a package name as input, SAVE saves all procedures and
variables, except those in buried packages. If you specify a package or a list
of packages, only the procedures and variables in the input-named package(s)
are saved. SAVE can save buried procedures and variables if you specify a
buried package name.
Examples:
These examples assume you have three packages named FLY, SHAPES, and SIZES in
your workspace.
?popkg
fly is buried
to buzz
to fly
to zoom
shapes
to circle :size
to triangle :size
to square :size
sizes
"big (VAL)
"medium (VAL)
"small (VAL)
?save "Sheila
?save "fly "fly
?save "shapes [shapes sizes]
?dir
[SHAPES.LOG FLY.LOG SHEILA.LOG]
(ROCHE> I found the following procedure useful... For multiple saves.)
to sav :fname
erasefile :fname
save :fname
end
savepic
-------
Action:
Writes the picture (on the screen) to the input-named disk file.
Syntax:
savepic fname fname
Explanation:
SAVEPIC writes the contents of the screen to the input-named disk file. If
there is already a file with the specified name on the disk, SAVEPIC displays
the message "File already exists." Choose another name for the new file,
delete the old file with ERASEFILE, or rename it with CHANGEF. If there is no
file with the specified name on the disk, SAVEPIC creates one with the file
type PC0. (ROCHE> for SETRES 0 images. But images saved under SETRES 1 are
given the PC1 file type... and DIRPIC is then unable to find them! This is
clearly a bug. The solution is to use an ambiguous filespec, with .PC? for the
file type.) File names in the disk's directory cannot be longer than eight
characters. So, if you specify a file name with more than eight characters,
SAVEPIC truncates the file name to eight characters.
Examples:
?savepic "shapes
?dirpic
[SHAPES.PC0 PLAID.PC0 PIGLATIN.PC0]
?dirpic "p???????.pc?
[PLAID.PC0 PIGLATIN.PC0 PLAID.PC1 PIGLATIN.PC1]
screenfacts sf
--------------
Action:
Outputs a list that contains information about the screen.
Syntax:
screenfacts
sf
Explanation:
Outputs a list that contains: Background color number of the viewport; Screen
state; Split size; Window state; Scrunch ratio; Zoom factor; X-coordinate and
Y-coordinate of viewport center; Current resolution setting.
Examples:
?screenfacts
[0 ts 5 window 1 1 0 0 0]
?to screen.facts
>print []
>type [Background Color Number:\ ] print item 1 screenfacts
>type [Screen state:\ ] print item 2 screenfacts
>type [Split Size:\ ] print item 3 screenfacts
>type [Window State:\ ] print item 4 screenfacts
>type [Scrunch Ratio:\ ] print item 5 screenfacts
>type [Zoom Factor:\ ] print item 6 screenfacts
>(type [(X,Y) of Viewport Center:] (word "\( item 7 sf ", item 8 sf "\))
>print []
>type [Current Resolution Setting:\ ] print item 9 screenfacts
>print []
>end
screen.facts defined
?setres 0
?screen.facts
Background Color Number: 0
Screen state: ts
Split Size: 5
Window State: window
Scrunch Ratio: 1
Zoom Factor: 1
(X,Y) of Viewport Center: (0,0)
Current Resolution Setting: 0
?setres 1
?screen.facts
Background Color Number: 0
Screen state: ts
Split Size: 10
Window State: window
Scrunch Ratio: 0.5
Zoom Factor: 2
(X,Y) of Viewport Center: (0,0)
Current Resolution Setting: 1
?
sentence se
-----------
Action:
Outputs a list made up of the input objects.
Syntax:
sentence object object (...)
se object object (...)
Explanation:
SENTENCE outputs a list made up of the input objects. SENTENCE is like LIST
but removes the outermost brackets from the input objects.
Without punctuation, SENTENCE requires and accepts two input objects. SENTENCE
can accept more or fewer inputs when you enclose the SENTENCE expression in
parentheses ["(" and ")"]. If no other expressions follow the SENTENCE
expression on the line, you do not need to type the closing right parenthesis
[")"].
There are two ways of creating lists in Dr. Logo:
1) using square brackets ("[" and "]")
2) using LIST or SENTENCE
Each way results in a different kind of list. When you create a list by
enclosing elements in square brackets, you create a "literal" list. Dr. Logo
treats the elements of the list literally; it does not evaluate expressions or
look up the values of variables named in a literal list.
When you use LIST or SENTENCE to create a list, you can use variables and
expressions to specify the elements Dr. Logo will put in the list. You can use
LIST and SENTENCE to create a list for input to most procedures. However, IF,
IFFALSE, and IFTRUE require literal lists as input.
Examples:
?sentence "tortoise "hare
[tortoise hare]
?sentence "turtle []
[turtle]
?make "turtle (sentence readlist readlist readlist)
pecans
caramel
chocolate
?:turtle
[pecans caramel chocolate]
?sentence "hare [rabbit bunny]
[hare rabbit bunny]
?sentence [Slow and steady] [wins the race.]
[Slow and steady wins the race.]
?to use :what
>if memberp lowercase :what [green red yellow]
> [make "colornumber where
> make "state "pd]
>if "eraser = lowercase :what
> [make "state "pe]
>run (sentence "setpen "list "quote :state "quote :colornumber)
>end
use defined
?use "green forward 60 right 120
?use "red forward 60 right 120
?use "yellow forward 60 right 120
setbg (= SET BackGround)
-----
Action:
Sets the graphic screen background to the color represented by the input
number.
Syntax:
setbg n
Explanation:
SETBG sets the graphic screen background to the color represented by the input
number. The input number must be in the range from 0 to 63. The IBM Personal
Computer supports eight background colors in two levels of intensity, although
your color monitor might or might not display different intensities. The
numbers SETBG accepts represent colors as follows:
Low intensity
---------------------
0 16 32 48 Black
1 17 33 49 Blue
2 18 34 50 Green
3 19 35 51 Cyan
4 20 36 52 Red
5 21 37 53 Magenta
6 22 38 54 Yellow
7 23 40 55 White
High intensity
---------------------
8 24 40 56 Black
9 25 41 57 Blue
10 26 42 58 Green
11 27 42 59 Cyan
12 28 43 60 Red
13 29 45 61 Magenta
14 30 46 62 Yellow
15 31 47 63 White
Each of the four numbers for a background color specifies a different pen for
the turtle to use (see SETPC).
Examples:
When you first start Dr. Logo, FIRST SCREENFACTS returns 0, representing
Black, the default background color, with the turtle, pen, and text all
written in White. (Use SETBG 1 for a Blue background, with a Yellow turtle
leaving a White trail with its pen.) The BG.CYCLE procedure displays
background colors.
?to bg.cycle :val ; Displays background colors
>if :val = 0
> [print [Cycle complete.] setbg 0 stop]
>setbg :val
>(print [This is background color number] first screenfacts)
>wait 20000 ; 2 seconds on a 500-MHz PC
>bg.cycle :val - 1
>end
bg.cycle defined
?bg.cycle 7
This is background color 7
This is background color 6
This is background color 5
This is background color 4
This is background color 3
This is background color 2
This is background color 1
Cycle complete.
setcursor
---------
Action:
Positions the cursor at the location specified by the input text screen
coordinate list.
Syntax:
setcursor coord_list
Explanation:
SETCURSOR positions the cursor at the location specified in the input text
screen coordinate list. A text screen coordinate list has two elements: the
first element is the column number; the second, the line number. The line
number must be in the range 0 to 24. The column number must be in the range 0
to 79.
If either of the two input numbers exceed the allowed range, SETCURSOR uses
the highest allowable value: 24 for line number, or 79 for column number. If
you are using a splitscreen or other 40 column text screen, and specify a
column number greater than 40, SETCURSOR wraps the cursor to the next line, in
effect adding 1 to the input line number, and subtracting 40 from the input
column number.
Examples:
?to diagonal.type
>type readchar
>setcursor list (3 + first cursor) (1 + last cursor)
>diagonal.type
>end
diagonal.type defined
?cleartext
?setcursor [0 0]
?diagonal.type
H
e
l
l
o
,
w
o
r
l
d
!
setd (= SET Drive name)
----
Action:
Makes the specified drive the default drive.
Syntax:
setd d:
Explanation:
SETD makes the specified drive the default drive. Dr. Logo looks in the
directory of the disk in the default drive when you do not specify a drive
name in a disk command such as SAVE, LOAD, ERASEFILE, CHANGEF, or DIR. (ROCHE>
You need to type the colon (":") after the drive name. Normally, colon is used
to separate the drive from the file name. You say: "drive A", not "drive A:".)
Examples:
?setd "b:
?defaultd
B:
?setd "a:
?defaultd
A:
setheading seth
---------------
Action:
Turns the turtle to the absolute heading specified by the input number of
degrees.
Syntax:
setheading degrees_n
seth degrees_n
Explanation:
SETHEADING turns the turtle to the absolute heading specified by the input
number of degrees. If the input number is positive, SETHEADING turns the
turtle clockwise (right) from North to the input number of degrees, regardless
of the turtle's current heading. If the input number is negative, SETHEADING
turns the turtle counter-clockwise.
Examples:
?setheading 90
?setheading 180
?setheading -90
?to draw.compass :n
>if :n > 330
> [setheading 0 stop]
>penup setheading :n forward 50
>turtletext (word :n)
>back 50 right 23 forward 45 pendown forward 5 penup back 50
>drawcompass :n + 45
>end
draw.compass defined
?draw.compass 0
setpal (= SET PALette of RGB colors)
------
Action:
Assigns RGB colors to a pen_index.
Syntax:
setpal [pal_n RGB_list]
Explanation:
The colors are stored in a table called a palette. The palette has room for
256 colors. SETPAL assigns the color represented by RGB_LIST to the pen index
designated by PAL_N. The range of values for PAL_N are 0 through 256. RGB_LIST
must be made of 3 elements. Each element control one of the basic components
of the color.
The first element controls the Red component, the second element controls the
Green component, and the last element controls the Blue component. Each
component of the RGB_LIST can be from 0 to 63. A 0 turns off the component
color, and a 63 turns it at its maximum. The standard setting is 42. Half
intensity is 21.
Examples:
setpal [0 0 0 0] ; Black
setpal [0 0 0 42] ; Blue
setpal [0 0 42 0] ; Green
setpal [0 0 42 42] ; Cyan
setpal [0 42 0 0] ; Red
setpal [0 42 0 42] ; Magenta
setpal [0 42 21 0] ; "Yellow"
setpal [0 42 42 42] ; "White"
(ROCHE> To get real Yellow, use [0 63 63 0]. For White, use [0 63 63 63].)
setpan
------
Action:
Establishes the center point of the viewport.
Syntax:
setpan coord_list
Explanation:
Establishes the center point of the viewport.
Examples:
?setpan [50 50]
setpc (= SET Pen Color)
-----
Action:
Sets the turtle's pen to the color specified by the input number.
Syntax:
setpc n
Explanation:
SETPC sets the turtle's pen to the color specified by the input number. The
turtle has four pens. Each pen has four unique colors of ink, one of which is
the background color that the turtle uses for erasing. Which pen and set of
inks the turtle uses depends on the number you input to SETBG to specify the
background color.
Low intensity
---------------------
0 16 32 48 Black
1 17 33 49 Blue
2 18 34 50 Green
3 19 35 51 Cyan
4 20 36 52 Red
5 21 37 53 Magenta
6 22 38 54 Yellow
7 23 40 55 White
High intensity
---------------------
8 24 40 56 Black
9 25 41 57 Blue
10 26 42 58 Green
11 27 42 59 Cyan
12 28 43 60 Red
13 29 45 61 Magenta
14 30 46 62 Yellow
15 31 47 63 White
When the background color is in the range 0 to 15:
- pencolor 1 represents dark green ink
- pencolor 2 represents dark red ink
- pencolor 3 represents dark yellow ink
When the background color is in the range 16 to 31:
- pencolor 1 represents bright green ink
- pencolor 2 represents bright red ink
- pencolor 3 represents bright yellow ink
When the background color is in the range 32 to 47:
- pencolor 1 represents dark cyan ink
- pencolor 2 represents dark magenta ink
- pencolor 3 represents dark grey ink
When the background color is in the range 48 to 63:
- pencolor 1 represents bright cyan ink
- pencolor 2 represents bright magenta ink
- pencolor 3 represents bright white ink
For all background color numbers, pencolor 0 represents background color
(erasing) ink. The turtle itself is drawn with pencolor 3.
Examples:
?to pc.cycle :penc :bkgr
>if :penc > 3
> [change.bg]
>if :bkgr > 50
> [stop]
>setpc :penc
>(print [This is pencolor] item 5 tf)
>repeat 36
> [forward 4 right 10] back 20
>wait 20000 ; 2 seconds on a 500-MHz PC
>pencolor.cycle (:penc + 1) :bkgr
>end
pc.cycle defined
?to change.bg
>make "bkgr 16 + :bkgr
>if :bkgr > 50
> [stop]
>setbg :bkgr
>(print [Background color] output first sf)
>make "penc 1
>end
change.bg defined
?clearscreen home left 90 forward 120 clean splitscreen setbg 1
?pc.cycle 1 1
This is pencolor number 1
This is pencolor number 2
This is pencolor number 3
Background color 17
This is pencolor number 1
This is pencolor number 2
This is pencolor number 3
Background color 33
This is pencolor number 1
This is pencolor number 2
This is pencolor number 3
Background color 49
This is pencolor number 1
This is pencolor number 2
This is pencolor number 3
setpen
------
Action:
Sets the turtle's pen to the state and color specified in the input list.
Syntax:
setpen list
Explanation:
SETPEN sets the turtle's pen to the state and color specified in the input
list. You can use SETPEN to change the pen's state and color with a single
command; for example, SETPEN [PD 2] is equivalent to PENDOWN SETPC 2.
The first element of the input list must be one of PENDOWN, PENERASE, PENUP,
or PENREVERSE. The second element must be a number that represents a pencolor
(see SETPC).
Examples:
?to pen
>output list item 4 turtlefacts item 5 turtlefacts
>end
pen defined
?pen
[pd 1]
?setpen [pe 0]
?pen
[pe 0]
?setpen [pd 1]
?to dandelion
>setheading first shuffle list (random 45) (-1 * (random 45))
>make "penstate pen
>forward 20 + random 80
>setpc 1 + random 3
>repeat 36
> [forward 10 back 10 right 10]
>penup setpos :root
>setpen :penstate
>dandelion
>end
dandelion defined
?make "root [0 -50]
?setpos :root clean
?dandelion
setpos (= SET turtle POSition)
------
Action:
Moves the turtle to the position specified in the input coordinate list.
Syntax:
setpos coord_list
Explanation:
SETPOS moves the turtle to the position specified in the input coordinate
list. The input list has the same two-element form as the list output by pos.
The first element is the X-coordinate, in the range -150 to +149. The second
element is the Y-coordinate, in the range -99 to +100.
If the graphic screen is FENCEd, values outside these ranges generate a
"Turtle out of bounds" message. When WINDOW is set, you can input coordinates
outside the ranges, to make the turtle plot off screen. When WRAP is set,
SETPOS converts any input coordinates that are outside the visible range, so
that the turtle WRAPs and remain visible.
Examples:
?clearscreen
?setpos [80 50]
?setpos [0 30]
?setpos [80 -50]
?setpos [0 0]
?to dandelion
>setheading first shuffle list (random 45) (-1 * (random 45))
>make "penstate pen
>forward 20 + random 80
>setpc 1 + random 3
>repeat 36
> [forward 10 back 10 right 10]
>penup setpos :root
>setpen :penstate
>dandelion
>end
dandelion defined
?make "root [0 -50]
?setpos :root clean
?dandelion
setprec (= SET PRECision of numbers)
-------
Action:
Sets the number of significant digits displayed in an output number.
Syntax:
setprec n
Explanation:
Sets the number of significant digits displayed in an output number.
Examples:
?setprec 10
setread (= SET file to READ)
-------
Action:
Sets the data file from which to receive input.
Syntax:
setread fname
Explanation:
Sets the data file from which to receive input. After this command, you use
READLIST, READCHAR, and READQUOTE to read the data from the file or device.
(ROCHE> There is a system message, saying that "Only 4 files can be open".)
Examples:
?open "telnos
?setread "telnos
?readlist
[TERRY CLOTH]
setres (= SET the RESolution of the screen)
------
Action:
Sets the resolution of the viewport.
Syntax:
setres n
Explanation:
Sets the resolution of the viewport. Available resolutions are 0 (320x200),
and 1 (640x480). Changes the default and maximum values for many of the
parameters that affect the appearance of the text and graphic displays.
+100 +239
┌────────────┐ ┌────────────┐
│ setres 0 │ │ setres 1 │
-160 │ │ +159 -320 │ │ +319
│ 320x200 │ │ 640x480 │
└────────────┘ └────────────┘
-99 -240
Examples:
?screenfacts
[0 ts 5 window 1 1 0 0 0]
?to screen.facts
>print []
>type [Background Color Number:\ ] print item 1 screenfacts
>type [Screen state:\ ] print item 2 screenfacts
>type [Split Size:\ ] print item 3 screenfacts
>type [Window State:\ ] print item 4 screenfacts
>type [Scrunch Ratio:\ ] print item 5 screenfacts
>type [Zoom Factor:\ ] print item 6 screenfacts
>(type [(X,Y) of Viewport Center:] (word "\( item 7 sf ", item 8 sf "\))
>print []
>type [Current Resolution Setting:\ ] print item 9 screenfacts
>print []
>end
screen.facts defined
?setres 0
?screen.facts
Background Color Number: 0
Screen state: ts
Split Size: 5
Window State: window
Scrunch Ratio: 1
Zoom Factor: 1
(X,Y) of Viewport Center: (0,0)
Current Resolution Setting: 0
?setres 1
?screen.facts
Background Color Number: 0
Screen state: ts
Split Size: 10
Window State: window
Scrunch Ratio: 0.5
Zoom Factor: 2
(X,Y) of Viewport Center: (0,0)
Current Resolution Setting: 1
?
(ROCHE> You will note the following differences between Resolution 0 and
Resolution 1:
Res0 Res1
---- ----
1) Split Size: 5 10
2) Scrunch Ratio: 1 0.5
3) Zoom Factor: 1 2
I don't know if it is a bug, but SETRES 1 "scrunch" the picture vertically by
half. If you use SETSCRUNCH 1, you recognize your Resolution 0 image. If you
then use SETZOOM 1, the image fills the screen, just like the Resolution 0
image, but with finer pixels. However, it would be silly to use less than half
the resolution of VGA. So, the only logical thing to do is:
1) SETRES 1
2) SETSCRUNCH 1
3) SETZOOM 1
4) SETSPLIT 5 (optional)
to get a real VGA graphics screen (640x480), then rewrite all your old 300x200
pixels (EGA) programs to fill this VGA screen. And don't forget that the
workspace is four times bigger than the 8-bits version of Dr. Logo... If you
want to see the increase in pixels between SETRES 0 and SETRES 1, run the
following procedure, after FRAME1 (see FENCE).)
to frame
pu setpos [-160 99] pd
setx 159
sety -100
setx -160
sety 100
pu home st
end
.setseg
-------
Action:
Sets segment value.
Syntax:
.setseg segment_n
Explanation:
Sets segment value to be used by subsequent .DEPOSIT and .EXAMINE expressions.
Does not change the segment register.
Examples:
?.setseg 23
setscrunch (= SET SCRUNCH ratio)
----------
Action:
Sets the viewport vertical aspect ratio.
Syntax:
setscrunch n
Explanation:
Sets the viewport vertical aspect ratio to the input number that can be from 1
through 5.
Examples:
?setscrunch 5
setsplit
--------
Action:
Sets the number of lines in the splitscreen's text window.
Syntax:
setsplit n
Explanation:
SETSPLIT sets the number of lines in the splitscreen screen window. The input
number must be in the range 0 to 25.
Examples:
?repeat 12 [repeat 5 [forward 50 right 72] right 30]
?setpc 1
?splitscreen
?setsplit 15
?setsplit 1
?setsplit 5
setwrite (= SET file to WRITE)
--------
Action:
Sets the destination of outputs.
Syntax:
setwrite fname | device
Explanation:
Sets the destination of outputs from PRINT, TYPE, and SHOW to the data file or
system device. The file or device must already be OPEN. SETWRITE sets the file
position at the top of the file.
(ROCHE> The devices are: CON: NUL: PRN: and AUX: There is a system message,
saying that "Only 4 files can be open".)
Examples:
?open "phones
?setwrite "phones
setx (= SET X-coordinate)
----
Action:
Moves the turtle horizontally to the X-coordinate specified by the input
number.
Syntax:
setx n
Explanation:
SETX moves the turtle horizontally to the X-coordinate specified by the input
number. The Y-coordinate is not changed.
Examples:
?to frame
>penup setpos [-150 100] pd
>setx 149
>sety -99
>setx -150
>sety 100
>end
frame defined
?frame
sety (= SET Y-coordinate)
----
Action:
Moves the turtle vertically to the Y-coordinate specified by the input number.
Syntax:
sety n
Explanation:
SETY moves the turtle vertically to the Y-coordinate specified by the input
number. The X-coordinate is not changed.
Examples:
?to frame
>penup setpos [-150 100] pd
>setx 149
>sety -99
>setx -150
>sety 100
>end
frame defined
?frame
setzoom (= SET ZOOM ratio)
-------
Action:
Sets the screen to show more or less of the picture.
Syntax:
setzoom n
Explanation:
Causes the viewport to show a greater or lesser portion of the graphic plane,
thereby expanding or contracting subsequent turtle motion. Does not clear the
viewport, nor alter anything previously drawn.
Examples:
?setzoom 2
show
----
Action:
Displays the input object on the text screen.
Syntax:
show object
Explanation:
SHOW displays the input object on the text screen, followed by a Carriage
Return. SHOW does not remove the outer brackets from an input list. Compare
show with PRINT and TYPE.
You can input any number of objects by preceding SHOW with a left parenthesis
["("]. When preceded by a parenthesis, SHOW displays all its inputs on the
same line, and follows only the last input with a Carriage Return.
Dr. Logo's interpreter has an implicit SHOW command. This means that, when you
enter an expression that outputs an object to the ? prompt, Dr. Logo shows the
output object, instead of complaining that it does not know what to do with
it.
Examples:
?show "K
K
?show [crab scallops clams]
[crab scallops clams]
?3 * 10
30
?to demo :list
>make "success "FALSE
>catch "error [do.it]
>if :success = "TRUE
> [stop]
>make "error1 error
>if 52 = first :error1
> [do.it]
> [print first butfirst :error1]
>end
demo defined
?to do.it
>type "? print :list
>run :list
>make "success "TRUE
>end
do.it defined
?to do.it1
>show run :list
>make "success "TRUE
>end
?do.it1 defined
?to logo.demo
>print []
>print [Here's how Dr. Logo responds to some commands:]
>print []
>demo [make "side 80]
>demo [repeat 4 [forward :side right 90]]
>demo [fence]
>demo [:side]
>demo [repeat 2 [back :side]]
>print []
>print [That's all, folks!]
>print []
>end
logo.demo defined
?logo.demo
Here's how Dr. Logo responds to some commands:
?make "side 80
?repeat 4 [forward :side right 90]
?fence
?:side
80
?repeat 2 [back :side]
Turtle out of bounds
That's all, folks!
?
showturtle st
-------------
Action:
Makes the turtle visible if hidden.
Syntax:
showturtle
st
Explanation:
SHOWTURTLE makes the turtle visible. When invisible, the turtle draws faster,
and does not distract visually from the drawing. To make the turtle invisible,
enter HIDETURTLE (HT).
Examples:
?hideturtle
?showturtle
?to face
>hideturtle forward 90
>make "chin pos
>setpc 3 repeat 36 [forward 6 left 10]
>setpc 1 left 90 penup forward 30 left 90 forward 20 setheading 0 eye
>setheading 90 forward 30 setheading 0 eye
>setpc 2 setheading 150 forward 10 setheading 180 mouth
>setpos :chin setheading 0
>forward 23 left 5
>end
face defined
?to eye
>pendown repeat 18 [forward 1 right 10]
>right 100
>repeat 8
> [forward 1.5 left 6]
>pu
>end
eye defined
?to mouth
>pd
>repeat 18
> [forward 2 right 10]
>right 100
>repeat 8
> [forward 3 left 6]
>pu
>end
mouth defined
?face
?showturtle
shuffle
-------
Action:
Outputs a list that contains the elements of the input list in random order.
Syntax:
shuffle list
Explanation:
SHUFFLE outputs a list that contains the elements of the input list in random
order.
Examples:
?shuffle [a b c d]
[c b d a]
?to pick.a.card
>output word
> first shuffle [A K Q J 10 9 8 7 6 5 4 3 2]
> char first shuffle [3 4 5 6]
>end
pick.a.card defined
?repeat 4 [(type pick.a.card char 9)]
7Hearts 7Clubs KDiamond JSpade
(ROCHE> On the IBM PC, the values 3, 4, 5, and 6 (of Code Page 850) generate
the symbols of the playing cards (Hearts, Diamond, Clubs, and Spade,
respectively). Since WordStar uses control codes for its inner working, they
are replaced, in the above example, by their names. When run on an IBM PC, the
above program would dislay 7* 7* K* J*, where * would be the symbol.)
sin
---
Action:
Outputs the sine of the input number of degrees.
Syntax:
sin degrees_n
Explanation:
SIN outputs the trigonometric sine of the input number of degrees. SIN outputs
a decimal number between 0 and 1.
Examples:
?sin 90
1
?to plot.sine
>make "val 0
>make "x -150
>make "inc (300 / 60)
>setx 150 setx :x
>plot.s :val
>end
plot.sine defined
?to plot.s :val
>if :x > 150
> [stop]
>make "y (90 * (sin :val)) ; 90 makes plot visible
>setheading towards list :x :y
>setpos list :x :y
>make "x :x + :inc
>make "val :val + 6
>plot.s :val
>end
plot.s defined
?plot.sine
sort
----
Action:
Outputs a list of input words sorted into ascending order.
Syntax:
sort list
Explanation:
SORT takes a list as input, then outputs, in ascending order, the elements of
the input list.
Examples:
?sort .contents
?sort glist ".PRM
splitscreen ss
--------------
Action:
Displays a window of text on the graphic screen.
Syntax:
splitscreen
ss
Explanation:
SPLITSCREEN displays a window of text on the graphic screen. A SPLITSCREEN
command is equivalent to a Ctrl-S keystroke. Use SETSPLIT to specify the
number of lines of text in the text window.
Examples:
?clearscreen repeat 12 [repeat 4 [forward 60 right 90] right 30
?splitscreen
?repeat 12 [repeat 4 [forward 60 right 90] right 30]
?splitscreen
sqrt (= SQuare RooT)
----
Action:
Outputs the square root of the input number.
Syntax:
sqrt n
Explanation:
SQRT outputs the square root of the input number.
Examples:
?sqrt 2
1.4142135623731
?to measure :xypair1 :xypair2
>make "x1 first :xypair1
>make "x2 first :xypair2
>make "xdif :x2 - :x1
>make "y1 last :xypair1
>make "y2 last :xypair2
>make "ydif :y2 - :y1
>make "xdif2 :xdif * :xdif
>make "ydif2 :ydif * :ydif
>output sqrt (:xdif2 + :ydif2)
>end
measure defined
?make "p1 [-75 -49]
?setpos :p1 clean
?make "p2 [75 30]
?setpos :p2
?measure :p1 :p2
169.53170794869
?make "p3 [50 -90]
?setpos :p3
?measure :p2 :p3
122.576506721313
?setpos :p1
?measure :p3 :p1
131.552270980018
STARTUP (Not a primitive)
-------
A STARTUP file is a file that Dr. Logo automatically loads into the workspace
when you start your Dr. Logo system. Dr. Logo interprets each line loaded from
the file as if you typed it at the keyboard to the ? prompt. This makes any
procedures stored in the STARTUP.LOG file available immediately when you start
your Dr. Logo system. If you use EDF to create the STARTUP.LOG file, you can
include stand-alone expressions that automatically execute the procedures in
the file.
Your STARTUP.LOG file must always be on your system disk, so that Dr. Logo can
find it when you are starting your system. To see the contents of the
STARTUP.LOG file, enter:
?edf "startup
You can change the STARTUP.LOG file to contain your own procedures and execute
your own commands. Sometimes, it is useful to PACKAGE and BURY procedures in
the STARTUP.LOG file, so that they will not be displayed by workspace
management commands, or included in other files saved during the session. Note
that Dr. Logo does not automatically make a backup copy of your original file
on disk, so use EDF carefully.
stop
----
Action:
Stops the execution of the current procedure, and returns to toplevel or the
calling procedure.
Syntax:
stop
Explanation:
STOP stops the execution of the current procedure, and returns to the caller.
The caller is either the calling procedure or, if the procedure name was typed
at the ? prompt, toplevel. STOP has an effect only within a procedure. At
toplevel, STOP has no effect; it simply returns to toplevel. Compare STOP with
CATCH, THROW, OUTPUT, and END.
Examples:
?to vanish :object
>if emptyp :object
> [stop]
>print :object
>vanish butfirst :object
>end
vanish defined
?vanish "emperor
emperor
mperor
peror
eror
ror
or
r
sum +
-----
Action:
Outputs the sum of the input numbers.
Syntax:
sum n n (...)
+ n n (...)
Explanation:
SUM outputs the sum of the input numbers. SUM is equivalent to the +
arithmetic operator. Without punctuation, SUM requires and accepts two input
objects. SUM can accept more or fewer inputs when you enclose the SUM
expression in parentheses ["(" and ")"]. If no other expressions follow the
SUM expression on the line, you do not need to type the closing right
parenthesis [")"].
Examples:
?sum 5 9
14
?+ 5 9
14
?sum 2.565 7.9
10.465
?+ 2.565 7.9
10.465
?(sum 6 4 -7 9 3 -2 8
21
?(+ 6 4 -7 9 3 -2 9
21
tan
---
Action:
Outputs the tangent of the input angle.
Syntax:
tan degrees_n
Explanation:
TAN outputs the tangent of the angle represented by the input number of
degrees.
Examples:
?tan 0
0
?arctan 45
1
?to plot.tan
>make "val -pi
>make "inc pi / 37.5
>make "x -150
>setx 150
>setx :x
>plot.t :val
>end
plot.tan defined
?to plot.t :val
>if :x > 150
> [stop]
>forward 1000 * tan :val
>sety 0
>setx :x + 4
>make "x :x + 4
>make "val :val + :inc
>plot.t :val
>end
plot.t defined
?plot.tan
test
----
Action:
Remembers whether the input predicate is TRUE or FALSE for subsequent IFFALSE
and IFTRUE expressions.
Syntax:
test pred_exp
Explanation:
TEST remembers whether the input predicate is TRUE or FALSE for subsequent
IFFALSE and IFTRUE expressions. You can use TEST, IFFALSE, and IFTRUE instead
of IF to control the flow of execution within your procedure when you need Dr.
Logo to evaluate expressions after it evaluates a predicate expression, but
before it executes the chosen instruction list.
Examples:
The COIN5 procedure is similar to the COIN procedures shown as examples under
IF, but shows how to use TEST, IFFALSE, and IFTRUE. COIN5 evaluates an
expression after it evaluates a predicate expression, but before it executes
the chosen instruction list.
?to coin5
>test 1 = random 2
>if 1 = random 1000000
> [print [Landed on edge!] stop]
>iftrue [type "heads]
>iffalse [type "tails]
>print [\ side up]
>end
coin5 defined
text
----
Action:
Outputs the definition list of the specified procedure.
Syntax:
text procname
Explanation:
TEXT outputs the definition list of the specified procedure. The format of the
definition list is suitable for input to DEFINE. TEXT works by outputting the
value of the system property .DEF from the procedure's property list.
Examples:
?to star2 ; Five pointed star
>repeat 5
> [forward 30 left 217 forward 30 left 70]
>end
star2 defined
?star
?package "figures "star
?popkg
figures
to star2 ; Five pointed star
?plist "star2
[.PAK figures PKG TRUE.DEF [[] [repeat 5 [forward 30 left 217 forward 30 left
70]]] .FMT [[0]]
?text "star2
[[] [repeat 5 [forward 30 left 217 forward 30 left 70]]]
textscreen ts
-------------
Action:
Selects a full text screen.
Syntax:
textscreen
ts
Explanation:
TEXTSCREEN devotes the entire monitor to text. It can return to a full text
screen from a full graphic screen or splitscreen. If you have a single monitor
system, TEXTSCREEN is equivalent to a Ctrl-T keystroke. If you have a two-
monitor system (both a monochrome and color monitor), TEXTSCREEN is the only
way to display the text screen on the color monitor; Ctrl-T displays the text
screen on the monochrome monitor.
Examples:
?repeat 12 [repeat 4 [forward 60 right 90] right 30]
?splitscreen
?textscreen
thing
-----
Action:
Outputs the value of the input-named variable.
Syntax:
thing varname
Explanation:
THING displays the contents or value of the input-named variable. THING is
equivalent to a colon (":") before a variable name; for example, THING "KAREN
is equivalent to :KAREN. THING works by outputting the value of the system
property .APV from the input-named variable's property list.
Examples:
?name "chocolate "flavor
?thing "flavor
chocolate
?:flavor
chocolate
?make "chocolate "semi\-sweet
?thing "chocolate
semi-sweet
?thing "flavor
chocolate
?thing :flavor
semi-sweet
throw
-----
Action:
Executes the line identified by the input name in a previous CATCH expression.
Syntax:
throw name
Explanation:
THROW works with the CATCH primitive to let your procedure handle special
conditions. A THROW expression is valid only within the scope of a CATCH
command. The description of CATCH explains how to use CATCH and THROW.
CATCH and THROW each require a name as input. To pair a CATCH expression with
a THROW expression, you must give the CATCH and THROW expressions the same
input name. When a THROW command is executed, Dr. Logo returns to the
procedure that contains the CATCH command identified by the throw name. Dr.
Logo then executes the line that follows the CATCH command. THROW can accept
the special word "toplevel to return to the ? prompt (compare with STOP).
Examples:
The COIL procedure asks the user to enter increasingly larger numbers as the
turtle draws a coil on the screen. If the user types a number that is not
bigger than the last one entered, COIL reminds the user what to type, and
continues working.
?to coil
>print [Enter a small number.]
>make "previous 0
>forward grow.number
>right 30
>trap
>end
coil defined
?to grow.number
>make "growth first readlist
>if :growth < :previous
> [throw "not.bigger]
>make "previous :growth
>output :growth
>end
grow.number defined
?to trap
>catch "not.bigger [draw.coil]
>(print [Enter a number bigger than] :previous)
>trap
>end
trap defined
?to draw.coil
>print [Enter a bigger number.]
>forward grow.number
>right 30
>draw.coil
>end
draw.coil defined
The THROW "NOT.BIGGER instruction in the GROW.NUMBER procedure always returns
Dr. Logo to the TRAP procedure. If a STOP instruction had been used instead of
THROW, Dr. Logo would return to the procedure that called GROW.NUMBER, which
might be either COIL or DRAW.COIL.
The following procedures allow the user to type commands just as he normally
would to the Dr. Logo interpreter. However, if the user enters a command
incorrectly, the MY.MESSAGE procedure traps the normal Dr. Logo error message
and prints a custom message.
?to my.message
>catch "error [interpret]
>print "Oops! first butfirst error [!!!]
>print [What do you want to do about that?]
>run readlist
>my.message
>end
my.message defined
?to interpret
>print [What next, boss?]
>run readlist
>interpret
>end
interpret defined
?my.message
to (Not a primitive)
--
Action:
Indicates the beginning of a procedure definition.
Syntax:
to procname < inputs >
Explanation:
TO is a special word that indicates the beginning of a procedure definition.
At toplevel, TO signals Dr. Logo that you are starting to define a procedure,
and puts you in the procedure editor (the > prompt).
TO is not part of a procedure's definition list, and is not a primitive. You
can use "to" as a procedure or variable name, if you are confident that the
name will not cause undue confusion.
Examples:
?to pent
>repeat 5
> [forward 25 left 72]
>end
pent defined
tones
-----
Action:
Outputs a tone of the frequency and duration specified in the input list.
Syntax:
tones note_list
Explanation:
TONES outputs a note of the frequency and duration specified in the input
note_list. The input list must contain two numbers. TONES interprets the first
number as the frequency of the desired note. For example, 440 is the frequency
of concert A. TONES interprets the second number as the number of milliseconds
the tone is to last.
Examples:
?tones [440 250]
?to scale :freq
>repeat 14
> [type list " int 0.5 + :freq
> tones list 0.5 + :note 300
> make "note :note * :c]
>end
scale defined
?make "c (2 ^ (1 / 12))
?scale 440
440 466 494 523 554 587 622 659 698 740 784 831 880
?to play :song :speed
>make "note first :song
>if memberp :note :notes
> [make interval where]
>(type " :note)
>if :note = "R
> [tones list 0 :speed]
> [tones list 440 * (:c ^ :interval) :speed]
>play butfirst :song :speed
>end
play defined
?make "notes [A A# B C C# D D# E F F# G G# A' A#' B' C' C#' D' D#' E' F' F#'
G' G#']
?make "hb [G A' G C' B' R G A' G D' C' R' G G#' E' C' B' A' F' E' C' D' C']
?play :hb 60
?to play1 :song :speed
>make "note first :song
>if memberp :note :notes
> [make interval where]
>(type " :note)
>if :note = "R
> [tones list 0 :speed]
> [tones list 440 * (:c ^ :interval) :speed]
>if emptyp first butfirst :song
> [stop]
>make "note2 first butfirst :song
>if memberp :note2 :notes
> [make interval where]
>(type " :note2)
>if :note2 = "R
> [tones list 0 :speed * 4]
> [tones list 440 * (:c ^ :interval) :speed * 4]
>play butfirst butfirst :song :speed
>end
play1 defined
?make "turtle.song [D G A' A#' A' A#' R R A' A#' R R R D' R C' A#' A' G A' G
A' R R G F G A' R R C' A#' A' G F G F G R R F D# F G R R G G A' R G F# R D'
?play :turtle.song 14
D G A' A#' A' A#' R R A' A#' R R R D' R C' A#' A' G A' G A' R R G F G A' R R
C' A#' A' G F G F G R R F D# F G R R G G A' R G F# R D'
towards
-------
Action:
Outputs a heading that would make the turtle face the position specified in
the input coordinate list.
Syntax:
towards coord_list
Explanation:
TOWARDS outputs a heading that would make the turtle face the position
specified in the input coordinate list. To make the turtle turn towards the
position, use the output of TOWARDS as the input to SETHEADING.
Examples:
?cs
?towards [75 50]
56.3099324740202
?towards [-75 -50]
236.30993247402
?to plot.sine
>make "val 0
>make "x -150
>make "inc (300 / 60)
>setx 150 setx :x
>plot.s :val
>end
plot.sine defined
?to plot.s :val
>if :x > 150
> [stop]
>make "y (90 * (sin :val)) ; 90 makes plot visible
>setheading towards list :x :y
>setpos list :x :y
>make "x :x + :inc
>make "val :val + 6
>plot.s :val
>end
plot.s defined
?plot.sine
trace
-----
Action:
Turns on trace monitoring of all or specified procedure(s).
Syntax:
trace < procname | procname_list >
Explanation:
TRACE turns on trace monitoring of procedure execution. Tracing displays the
name of each procedure as it is called, and the name and value of each
variable as it is defined. It also displays the level number, the number of
procedures that have been called since a procedure was initiated at toplevel.
Tracing lets you observe details of your procedure's execution without
interrupting with PAUSEs. Use WATCH or Ctrl-Z if you want to PAUSE during
procedure execution.
Examples:
?to average :numbers
>make "total 0
>add.up :numbers
>print :total / count :numbers
>end
average defined
?to add.up :list
>if emptyp :list
> [stop]
>make "total :total + first :list
>add.up butfirst :list
>end
add.up defined
?trace
?average [1 2 3]
[1] Evaluating average
[1] numbers is [1 2 3]
[2] Evaluating add.up
[2] list is [1 2 3]
[3] Evaluating add.up
[3] list is [2 3]
[4] Evaluating add.up
[4] list is [3]
[5] Evaluating add.up
[5] list is []
2
?notrace
?average [1 2 3]
2
turtlefacts tf
--------------
Action:
Outputs a list of information about the turtle.
Syntax:
turtlefacts
tf
Explanation:
Outputs a list that contains: Turtle's X-coordinate; Turtle's Y-coordinate;
Turtle's heading; Pen state; Pen's color number; TRUE if the turtle is
visible, FALSE if not.
Examples:
?turtlefacts
[15 30 60 PE 3 FALSE]
?to turtle.facts
>print []
>type [Turtle's X\-coordinate:\ ] print item 1 tf
>type [Turtle's Y\-coordinate:\ ] print item 2 tf
>type [Turtle's Heading:\ ] print item 3 tf
>type [Pen State:\ ] print item 4 tf
>type [Pen Color:\ ] print item 5 tf
>type [Turtle Visible:\ ] print item 6 tf
>print []
>end
turtle.facts defined
?turtle.facts
Turtle's X-coordinate: 0
Turtle's Y-coordinate: 0
Turtle's Heading: 0
Pen State: pd
Pen Color: 15
Turtle Visible: TRUE
(ROCHE> SETRES does not modify the values of TURTLEFACTS. Note that, by
default, pen color is 15 (White) and background color is 0 (Black). Using
SETBG 1 will display a Blue background, with a Yellow turtle leaving a White
trail with its pen.)
turtletext tt
-------------
Action:
Displays the input object at the turtle's current location on the graphic
screen.
Syntax:
turtletext object
tt object
Explanation:
TURTLETEXT displays the input object on the graphic screen. The first
character of the input object appears to the right of the turtle's center
line, plus zero to four turtle steps (pixels) to align with the closest
character cell.
Like PRINT, TURTLETEXT removes the outer brackets from any input list, and
follows the last input item with a Carriage Return. Without punctuation,
TURTLETEXT requires and accepts one input object. TURTLETEXT can accept more
inputs when you enclose the TURTLETEXT expression is parentheses ["(" and
")"]. If no other expressions follow the TURTLETEXT expression on the line,
you do not need to type the closing right parenthesis [")"].
Examples:
?cs
?turtletext "home forward 10
?turtletext readquote forward 10
I want to go
type
----
Action:
Displays the input objects on the screen.
Syntax:
type object (...)
Explanation:
TYPE displays the input object on the screen, but does not follow the last
input object with a Carriage Return. TYPE removes the outer square brackets
("[" and "]") from an input list. You can input any number of objects by
preceding TYPE with a left parenthesis ["("]. When preceded by a parenthesis,
TYPE displays all its inputs on the same line. Compare TYPE with PRINT and
SHOW.
Examples:
?type [This is the turtle's position:] pos
This is the turtle's position: [-19 -21]
?to new.prompt :prompt
>(type :prompt " )
>run readlist
>new.prompt :prompt
>end
new.prompt defined
?new.prompt [Dr.\ Logo\>]
Dr. Logo> repeat 5 [forward 40 left 72]
Dr. Logo>
unbury
------
Action:
Restores the specified package(s) to workspace management commands.
Syntax:
unbury pkgname | pkgname_list
Explanation:
UNBURY restores the specified package or packages to workspace management
commands. UNBURY works by removing the bury property (.BUR) from the package's
property list. The description of BURY command tells how workspace management
commands treat buried packages.
Examples:
These examples assume you have the following in your workspace: a package
named FIGURES that contains two variables named BIG and SMALL and two
procedures named SQUARE and TRIANGLE, and a package named TITLES that contains
two procedures named PRAUTHOR and PRDATE.
?popkg
figures
"big (VAL)
"small (VAL)
to square
to triangle
titles
to prauthor
to prdate
?bury "titles
?popkg
figures
"big (VAL)
"small (VAL)
to square
to triangle
titles is buried
to prauthor
to prdate
?pots
to square
to triangle
?unbury "titles
?popkg
figures
"big (VAL)
"small (VAL)
to square
to triangle
titles
to prauthor
to prdate
?pots
to square
to triangle
to prauthor
to prdate
uppercase uc
------------
Action:
Outputs the input word with all alphabetic characters in uppercase.
Syntax:
uppercase word
uc word
Explanation:
UPPERCASE outputs the input word with all alphabetic characters converted to
uppercase.
Examples:
?uppercase "jones
JONES
?uppercase "BeckyAnn
BECKYANN
?to quiz
>print [Can you play the ocarina?]
>if "N = uppercase first rq
> [print [Me neither!]]
> [print [Wow, I have never met anyone who did!]
>end
quiz defined
?quiz
Can you play the ocarina?
Not really
Me neither!
wait
----
Action:
Stops execution for the amount of time specified by the input number.
Syntax:
wait n
Explanation:
WAIT stops execution for the amount of time specified by the input number.
WAIT interprets the input number as the number of 1/60ths of a second it is to
wait. For example, to stop for one second, use WAIT 60.
(ROCHE> This was the case for the IBM PC in the USA running at 4-MHz in 1981,
where the electrical current's frequency is 60-Hz. (In Europe, it is 50-Hz.)
However, on my 500-MHz European PC, WAIT 10000 waits 1 seconds.)
Examples:
?wait 60
?repeat 10 [type "tick wait 30 print "tock wait 30]
ticktock
ticktock
ticktock
ticktock
ticktock
ticktock
ticktock
ticktock
ticktock
ticktock
?to bg.cycle :val ; Displays background colors
>if :val = 0
> [print [Cycle complete.] setbg 0 stop]
>setbg :val
>(print [This is background color number] first screenfacts)
>wait 20000 ; 2 seconds on a 500-MHz PC
>bg.cycle :val - 1
>end
bg.cycle defined
?bg.cycle 7
This is background color 7
This is background color 6
This is background color 5
This is background color 4
This is background color 3
This is background color 2
This is background color 1
Cycle complete.
watch
-----
Action:
Turns on watch monitoring of all or specified procedure(s).
Syntax:
watch < procname | procname_list >
Explanation:
WATCH turns on expression-by-expression monitoring of procedure execution.
WATCH displays each expression before execution, and PAUSEs until you press
the (Enter) key. During the PAUSE, you can examine the values of local
variables, and experiment with variations of the expression before the
expression is actually executed. If you want the values of variables to be
displayed automatically, enable TRACE as well as WATCH.
WATCH also displays a number in square brackets ("[" and "]") before the
expression. This level number tells you how many procedures your procedure has
called since it began execution.
If you give WATCH a procedure name or a list of procedure names as input, only
the specified procedures are monitored. Otherwise, any procedure you initiate
at toplevel or call from within another procedure is monitored.
Normally, anything an expression displays on the text appears interspersed
with the information that WATCH displays on the screen.
To stop the WATCH step-by-step monitoring, enter NOWATCH.
Examples:
?to average :numbers
>make "total 0
>add.up :numbers
>print :total / count :numbers
>end
average defined
?to add.up :list
>if emptyp :list
> [stop]
>make "total :total + first :list
>add.up butfirst :list
>end
add.up defined
?watch
?average [1 2 3]
[1] In average, make "total 0
[1] In average, add.up :numbers
[2] In add.up, if emptyp :list [stop]
[2] In add.up, make "total :total + first :list
[2] In add.up, add.up butfirst :list
[3] In add.up, if emptyp :list [stop]
[3] In add.up, make "total :total + first :list
[3] In add.up, add.up butfirst :list
[4] In add.up, if emptyp :list [stop]
[4] In add.up, make "total :total + first :list
[4] In add.up, add.up butfirst :list
[5] In add.up, if emptyp :list [stop]
[1] In average, print :total / count :numbers
2
?nowatch
?average [1 2 3]
2
where
-----
Action:
Outputs the item number of the most recent successful MEMBERP expression.
Syntax:
where
Explanation:
WHERE outputs a number that identifies the location of an element within a
word or list if a MEMBERP expression containing that element and word or list
outputs TRUE. WHERE outputs the item number of the most recent successful
MEMBERP expression.
Examples:
?memberp "v" river
TRUE
?show where
3
?to use :what
>if memberp lowercase :what [green red yellow]
> [make "colornumber where
> make "state "pd]
>if "eraser = lowercase :what
> [make "state "pe]
>run (sentence "setpen "list "quote :state "quote :colornumber)
>end
use defined
?use "green forward 80 right 120
?use "red forward 80 right 120
?use "yellow forward 80 right 120
window
------
Action:
Allows the turtle to plot outside the visible graphic screen.
Syntax:
window
Explanation:
WINDOW allows the turtle to plot outside the visible graphic screen. When you
first start Dr. Logo, the turtle can go beyond the visible screen and return.
You can enter WRAP or FENCE to limit the turtle to on-screen plotting. To
resume offscreen plotting after a WRAP or FENCE command, enter WINDOW.
Examples:
?fence
?to squiral :side
>repeat 4
> [forward :side right 90]
>right 20
>squiral :side + 5
>end
squiral defined
?squiral 20
Turtle out of bounds in squiral: repeat 4 [forward :side right 90]
?window
?squiral 20
Ctrl-G
word
----
Action:
Outputs a word made up of the input words.
Syntax:
word word word (...)
Explanation:
WORD outputs a word made up of the input words. Without punctuation, WORD
requires and accepts two input objects. WORD can accept more or fewer inputs
when you enclose the WORD expression in parentheses ["(" and ")"]. If no other
expressions follow the WORD expression on the line, you do not need to type
the closing right parenthesis [")"].
Examples:
?word "Hocus "Pocus
HocusPocus
?word 23 "skiddoo
23skiddoo
?(word "ab "ra "ca "da "bra
abracadabra
?to make.string :list
>if emptyp :list
> [output "]
>output (word first :list char 32 make.string butfirst :list)
>end
make.string defined
?repeat 2 make.string [forward 40 right 160]
?forward 40 right 160
?forward 40 right 160
wordp (= WORD Predicate)
-----
Action:
Outputs TRUE if the input object is a word or a number.
Syntax:
wordp object
Explanation:
WORDP outputs TRUE if the input object is a word or a number. Otherwise, WORDP
outputs FALSE.
Examples:
?wordp "Naima
TRUE
?wordp 50
TRUE
?wordp [word]
FALSE
?wordp butfirst [green red yellow]
FALSE
?to list.memberp :word :list
>if emptyp :list
> [output "FALSE]
>if wordp first :list
> [if :word = first :list
> [output "TRUE]
> [output list.memberp :word butfirst :list]]
>if list.memberp :word first :list
> [output "TRUE]
>output list.memberp :word butfirst :list
>end
list.memberp defined
?make "address.book [[name [Mr. President]] [street [1600 Pennsylvania
Avenue]] [city/state [Washington D.C.]]]
?list.memberp "Washington :address.book
TRUE
?list.memberp "Oregon :address.book
FALSE
wrap
----
Action:
Makes the turtle re-appear on the opposite side of the screen when it exceeds
the boundary.
Syntax:
wrap
Explanation:
WRAP makes the turtle re-appear on the opposite side of the graphic screen
when it moves beyond an edge. While WRAP is set, the turtle never leaves the
visual field. To allow the turtle to plot offscreen, enter WINDOW.
Examples:
?wrap
?forward 180
?cs
?to plaid
>wrap
>setpc 3 right 40 forward 10965
>setpc 2 right 90 forward 5000
>setpc 1 penup right 90 forward 6 pendown ht
>repeat 625
> [forward 3 left 90 forward 1 right 90 back 3 left 90 forward 1 right 90]
>end
plaid defined
?plaid
writer
------
Action:
Outputs the current data file.
Syntax:
writer
Explanation:
Outputs the current data file that is open for writing.
(ROCHE> There is a system message, saying that "Only 4 files can be open".)
Examples:
?writer
[A:ADDRESS.DAT]
xcor
----
Action:
Outputs the X-coordinate of the turtle's current position.
Syntax:
xcor
Explanation:
XCOR outputs the X-coordinate of the turtle's current position. XCOR is
equivalent to a FIRST POS expression.
Examples:
?clearscreen xcor
0
?to jump
>setpos list
> random 150 * first shuffle [1 -1]
> random 100 * first shuffle [1 -1]
>end
jump defined
?jump xcor
145
?jump xcor
-64
ycor
----
Action:
Outputs the Y-coordinate of the turtle's current position.
Syntax:
ycor
Explanation:
YCOR outputs the Y-coordinate of the turtle's current position. YCOR is
equivalent to a LAST POS expression.
Examples:
?clearscreen ycor
0
?to jump
>setpos list
> random 150 * first shuffle [1 -1]
> random 100 * first shuffle [1 -1]
>end
jump defined
?jump ycor
36
?jump ycor
49
EOF