DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
G2++ Tutorial - G2++(C++)

Record Definition

G2 records are themselves defined with a G2 record. For instance, the G2 record in example 1 could be defined by

   usr     20

This G2 record is a definition (or prototype) for the class of usr records whose value is a string whose maximum length is 20 characters. The following two G2 definitions/records are suitable for the G2 records in examples 2 and 3 above.

   usr
   log     10
   id      8
   gid     8
   name    40

and

   usr
   log     10
   id
   	usr     8
   	grp     8
   name    40
   proj
   	4       6

Example 4

In the array proj, the index 4 is taken to mean the number of array elements. G2 arrays have zero as the origin. Thus, the highest defined index in this case would be 3.

In the above example proj was a simple array. G2 also has more complicated arrays. For example,

   proj
   5
   	main    10
   	sub     10

Here, we have defined a G2 record with an array proj of 5 records, each with members main and sub.

A sample instance of one such defined record is

   proj
   0
   	main    141433
   1
   	main    141435
   	sub     0122

Note that there is no subf field in the first element of proj. Since G2 only represents non-null strings, the value of sub is, by definition, the null string.

In addition to character string, the following ``types'' can appear in a G2 record definitions: LONG, SHORT, and CHAR. Thus, if the usr and grp fields in example 4 were known to always be short and a long integer values, respectively, then we could rewrite the definition as follows:

   usr
   log     10
   id
   	usr     SHORT
   	grp     LONG
   name    40
   proj
   	4       6

Next topic: C Interface
Previous topic: Language Syntax

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005