|
|
|
< routines |
Variables |
local & global > |
|
|
A variable is a name tag to which we can assign a value. We can then retrieve the value later by referring to the variable name. System variables are created by Tymless to hold information related to the turtle and the program itself. They all begin with a dollar character $ and may include other special characters. You can also create your own 'user-defined variables'. These must start with a letter, but can contain any number of letters and numbers mixed together. // a polygon with variable sides and colour The random integer function ?: returns a random integer between 1 and 10 inclusive. This is assigned to variable numsides. Variables are not limited to numbers. Then can also be assigned text, colours, locations, shapes, aliases and structures, with one important restriction: if the value is changed, the new value must be of the same type as the old. For example you cannot assign text to a number variable. The program will terminate with an error message. name = "fred" |
|
< routines |
local & global > |