next up previous contents
Next: Flow Control Up: Variables, data types Previous: arrays   Contents

Structures

For some purposes, arrays are not flexible enough. One might want a variable to contain elements of different types. If, for example, you wanted to keep information about a person in one variable, you might want to record his or her name (a string), age (an integer), height (a float). You can set up such variables, called structures, like this:

elvis={person,name:'Elvis Aaron Presley',age:64,height:1.7}
bill={person,name:'William Jefferson Clinton',age:58,height:1.85}

You can then access the different elements of the structures like this:

print,elvis.name
Elvis Aaron Presley
print,bill.age
      58

Giving your newly-defined type of variable a name (`person' in this case) is optional.

Note

help,elvis      ; is not that helpful
help,elvis,/str ;is much more so.


John Marsham 2005-04-22