class Name [(parameter, ...)] record Field, ... type Name record Field, ...
A record type is a resticted form of the structure type in that it has a fixed binary layout. It is used for raw and direct access input and output and is also useful when calling procedures in foreign languages (e.g. C/C++). It enables portable external data sharing and is recommended for application program interfaces (API), libraries, remote procedure calls, messaging between processes, and sharing data files.
The binary record is layed out in the order the fields are defined. Each field is aligned to the size of the type and padding is used between fields as needed. No padding is applied at the end. The record alignment is the largest field width and no other alignement can be specified.
Enumerated types are not packed in a record. A structure may pack enumeration together. If enermerations only use a small number of bits a structure may be laid out in adjacent bits. A record puts each enumeration in its own Byte or if over 255 items, a Parcel. Consequently you can use pointers to reference enumerations in a record. If they are in a structure where they are packed they may not be on a byte boundary and you will get a compilation error is you reference them with a pointer.
Within a program the byte order is the native byte order of the process. If you are calling a procedure in a foreign language it will have the native ordering. When perfoming raw or direct input an output the byte order is designated on the Open command. Padding is not written nor read when performing raw input and output.
Record fields consist soley of numeric and enumerated types. Fixed length arrays of these types are also allowed. Records are flat in that fields cannot be other records or structures. Pointers are not allowed in records as well. Micros and macros may be included.
type Example record &An example of a record declaration Size word, &Integer type (4 bytes) Name[15] byte, &A string field limited to 16 characters Value cell, &Widest type determines alignment (8 bytes) Id Identifier :An enumeration (1 or 2 bytes)
String values can be stored in an array field of bytes, but it requires a fixed maximum size. Fixed point real numbers can be stored in integers. With the integer form function you can include a decimal point in the format pattern. This also avoids unintended rounding that can happen using floating point numbers in applications such as finance.
form( 500099, "$$$,$$$,$$$.dd" ) => " $5,000.99"
Unless a record is always processed on machines with the same architecture, floating point numbers should be serialized as text. For the best accuracy they can use the real form function with hexadecimal format patterns. It is also risky to pass Nans (not a number).