next up previous contents
Next: Flow Control Up: Arrays Previous: A word of warning   Contents

Structures

Structures can contain variables of different types. Defined using {} or CREATE_STRUCT. They dont get used very often, so do not worry if you dont understand them right now.

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

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
ELVIS           STRUCT    = -> PERSON Array[1]
help,elvis,/str ;is much more so. 
** Structure PERSON, 3 tags, length=20, data length=18:
   NAME            STRING    'Elvis Aaron Presley'
   AGE             INT             64
   HEIGHT          FLOAT           1.70000


John Marsham 2009-12-07