Getting Started Documentation Glish Learn More Programming Contact Us
Version 1.9 Build 1556
News FAQ
Search Home


next up previous
Next: Strings Up: NOTE 195 Getting Started with Glish for AIPS++ Previous: Loops and Conditionals

Records and Attributes

Scalars and arrays of the standard data types are not the only variables allowed by glish. Heterogeneous data structures, called records, can be treated as a single variable. These can be passed as arguments to a function and returned as a unit in a function return value. A record may be created all at once or added to piece by piece.

- header := [name='3C273', ra=12.12345, dec=2.3318]
- header.flux := 27.6
- header.type := 'quasar'
- print header.ra
12.12345

Record members may be strings, any of the numeric data types including arrays, as well as other records.

Any glish variable may be assigned attributes. For example,

- velocity::definition := 'relativistic'
- header.flux::units := 'Jy'

The distinction between record members and variable attributes is a subtle one, and it is seldom clear which is best suited to a particular application. Both record members and attributes may be accessed by name or by number. All of the following are acceptable:

- header.ra
- header[2]
- header['type']
- velocity::[1]
- velocity::definition
- velocity::['definition']

Numeric access lends itself to stepping through the fields or attributes with a loop index. Record field names may be retrieved with the built-in function 'field_names()', which returns a string.

- field_names(header)
name ra dec flux type

The empty attribute construct returns the attributes of a variable as a record, so you can use the 'field_names()' function on attributes, too.

- velocity::
[definition=relativistic]
- field_names(velocity::)
definition


next up previous
Next: Strings Up: NOTE 195 Getting Started with Glish for AIPS++ Previous: Loops and Conditionals
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc., Washington, D.C.

Return to AIPS++ Home Page
2006-10-15