Re: Unconstrained arrays in nested record structures

"Warren W. Gay VE3WWG" <[email protected]>
Newsgroups gmane.comp.gcc.gnat
Message-ID <[email protected]>
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 ;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.