HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
RECORD (extension)
Chapter 10450
Simple field references can appear wherever a variable can appear. The following assigns
values to the fields of record r of structure struct:
STRUCTURE /struct/
INTEGER i
REAL a
END STRUCTURE
RECORD /struct/ r
r.i = r.i + 1
r.a = FLOAT(r.i) - 2.7
Composite assignment is allowed for two records or two composite fields of the same
structure—that is, the record declaration statements for both records must have specified the
same
struct-name
. For example, the following is legal:
STRUCTURE /string/
BYTE len
CHARACTER*1 str(254)
END STRUCTURE
RECORD /string/ str1, str2
str1 = str2
The following example is also valid and uses composite assignment to assign the value of the
record edate of structure date to a field of the same structure (when) in the record event:
STRUCTURE /event/
CHARACTER*20 desc
STRUCTURE /date/ when
BYTE month, day
INTEGER*2 year
END STRUCTURE
END STRUCTURE
RECORD /date/ edate
RECORD /event/ event
edate.month = 1
edate.day = 6edate.year = 62
event.desc = 'Party for Joanne'
! composite assignment of record to field
! of record--both have same structure
event.when = edate
Even though the following records are of identical structures—that is, the fields of both
structures have the same type, size, and format—the code is invalid because the structures
have a different name:
STRUCTURE /intarray/
BYTE elem_count
INTEGER arr(100)
END STRUCTURE