help-gnat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unconstrained arrays in nested record structures


From: Warren W. Gay VE3WWG
Subject: Re: Unconstrained arrays in nested record structures
Date: Wed, 21 May 2003 14:00:54 -0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02

I believe that the only way this can work, is if
you add a record discriminant to the record, that
you can then use as the size. For example (N below):

type DTED_FILE_RECORD_TYPE(N : Positive) is record
   UHL_RECORD                      : STRING (1..1) ;
   DSI_RECORD                       : STRING (1..1) ;
   ACC_RECORD                      : STRING (1..1) ;
   DTED_DATA_RECORD          : RECORD_ARRAY_TYPE_1 ( 1 .. N ) ;
end record ;

If you plan to use Ada.Direct_IO, then I think you'll
also need to have a default value for the discrimant
N as well.

BTW, you posted your message in HTML, which may not
be what you really want on an email list/newsgroup.

Warren.

Prichard, Jayson wrote:

I am trying to design a nested record structure with each record having an unconstrained array. Can anyone tell me if the following is possible in Ada/GNAT? How should this structure be accessed?

 type RECORD_ARRAY_TYPE_2  is array ( INTEGER range <> )
    of INTEGER ;


 type DTED_DATA_RECORD_TYPE is record
    DDR_RECOGNITION                     : STRING (1..1) ;
    DDR_DATA_BLOCK_COUNT         : STRING (1..1) ;
    DDR_LONGITUDE_COUNT            : STRING (1..1) ;
    DDR_LATITUDE_COUNT               : STRING (1..1) ;
DTED_ELEVATION_RECORD : RECORD_ARRAY_TYPE_2 ( 1 .. NUMBER_OF_ELEVATION_POSTS_PER_CELL ) ;
    DDR_CHECKSUM                         : STRING (1..1) ;
 end record ;

 type RECORD_ARRAY_TYPE_1  is array ( INTEGER range <> )
    of DTED_DATA_RECORD_TYPE ;

 type DTED_FILE_RECORD_TYPE is record
    UHL_RECORD                      : STRING (1..1) ;
    DSI_RECORD                       : STRING (1..1) ;
    ACC_RECORD                      : STRING (1..1) ;
DTED_DATA_RECORD : RECORD_ARRAY_TYPE_1 ( 1 .. NUMBER_OF_RECORDS_PER_CELL ) ;
 end record ;

   DTED_FILE_RECORD : DTED_FILE_RECORD_TYPE  ;

   DTED_DATA_FILE : DIRECT_IO.FILE_TYPE ;

 package DIRECT_IO is new ADA.DIRECT_IO ( DTED_FILE_RECORD_TYPE ) ;

   use DIRECT_IO ;






reply via email to

[Prev in Thread] Current Thread [Next in Thread]