|
|
|
< colours |
Structures |
aliases > |
|
|
A structure is a variable which contains more than one item of data. Each item is held in a kind of 'sub-variable' called a property or subscript. A property is accessed via a name beginning with a dot; a subscript via a number (or numeric expression) beginning with an underscore. ashape.name = "square" Here variable ashape contains two properties .name and .index, and also two subscripts 1 and 2. // program 3: output a random square number using
an array In this program, squareno is a structure containing an array of squares. A subscript can be:
Subscripts must be greater than zero, and will be rounded to the nearest whole number automatically. Structures can also be created by assigning a list to the variable, e.g. colourvalues = 1, 0, 0.5 The variable colourvalues now contains three subscripts. colourvalues_1 is 1, colourvalues_2 is 0, colourvalues_3 is 0.5 Some variables which are not user-defined structures will nevertheless contain system properties and subscripts, depending on the type of data they hold. A system property starts with dot dollar .$. For example, you can manipulate the various parts of a colour held in a variable through its system properties such as .$r ...
|
|
< colours |
aliases > |