MSW Logo Variables

Defining a Variable

A "variable" is something that can vary. To define a variable in MSW Logo use a statement in the form: MAKE "<variableName> <value> eg make "size 10. In this example the variable called "size" will now have a value of ten.

Using a Variable

If you want to make use of a variable in a procedure you must refer to it by writing a colon (":") in front of the variable name. In the example above you would refer to the variable in the form - :size. If you just write the word "size", without the colon, MSW Logo will treat it as text, rather than the value it contains.

to numbering
make "size 10
label :size
end

Variables can also be text, but when assigning the value it must be in square brackets. For example, after declaring - make "Name1 [Fred] the variable "Name1" will contain the text "Fred".

<- Back -Menu- Next ->