next up previous contents index
Next: Property Lists Up: The workspace Previous: Primitive 'trace'   Contents   Index

Concept of variables

There are two kinds of variables: In this version of LOGO, local variables are not accessible in sub-procedures. At the end of the procedure, the local variables are deleted.

Primitives Arguments Use
make a b: a word, b anything If the local variable a exists, assigns it the value b. If not, creates a global variable a and assigns it the value b.
Eg: make ``a 100 assigns the value 100 to the variable a
local a: word Creates a variable called a. Note, this is not initialised. To assign it a value, see make.
localmake a b: a word, b anything Creates a new local variable and assigns it the value b.
def, define word1 list2 list3
Define a new procedure called word1, which requires the variables in list2. The procedure's instructions are contained in list3.
def "polygon [nb length]
[repeat :nb[fd :length rt 360/:nb]]
--> this command defines a procedure called polygon with two variables (:nb and :length). This procedure draws a regular polygon, we can choose the number of sides and their length.
thing a: word returns the value of the variable :a. thing "a is similar to :a
erp, eraseprocedure a: word or list Deletes the procedure calling ''a`` or all procedures that contains the list ''a``.
erasevariable, erv a: word or list Deletes the variable ''a`` or all variables that contains the list ''a``
erasepropertylist, erpl a: word or list Deletes the property list ''a`` or all propert lists that contains the list ''a``
erall, eraseall none Deletes all the variables, property lists and procedures currently running.
bye a: none Quit XLogo.
procs, procedures none Returns a list which contains all the procedures currently defined.
variables, vars none Returns a list which contains all the defined variables.
pls, propertylists none Returns a list which contains all the property lists currently defined.
primitives none Enumerates all primitives for the current language.
contents none Returns a list which contains 3 lists. The first list contains all procedures names, the second all variables names and the last all propert lists names.
run a :list Executes the list of instructions contained in list a.



next up previous contents index
Next: Property Lists Up: The workspace Previous: Primitive 'trace'   Contents   Index
Loïc 2008-06-08