From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 20 Sep 91 18:58:18 GMT From: cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!usen et.coe.montana.edu!milton!mfeldman@ucbvax.Berkeley.EDU (Michael Feldman) Subject: Re: Message-ID: <1991Sep20.185818.3721@milton.u.washington.edu> List-Id: In article <1991Sep19.165920.1820@dayton.saic.com> hopperj@dayton.saic.com writ es: > >Type PRI_Stagger_Array is Array (Short_Integer Range <> ) of Short_Integer; > >Type InterceptReport is >Record > .... > EXT_Length : Short_Integer; > PRI_Per_Stagger : PRI_Stagger_Array(EXT_Length); >End Record; > >This will not compile. Is there some why to handle a variable size message >in Ada? Your best bet is to use a variant record, using Ext_Length as the discriminant. In order to let the record length vary, you'll have to give the discriminant a default value so the type can be unconstrained. Do you really think your message may be Short_Integer'Last elements long? (If Short_Integer is 16 bits in your compiler, this is 32767, kind of a long message). If not, use a subtype indicating the realistic maximum length, because some compilers allocate enough space to hold the maximum-length array This is a time/space tradeoff: some compilers prefer to reallocate, which saves space but costs time, others allocate for the maximum, which saves time but may cost a LOT of space if the type of your discriminant isn't realistic. Try these type defs: Type PRI_Stagger_Array is Array (Short_Integer Range <> ) of Short_Integer; Type InterceptReport (EXT_Length: Short_Integer := 8) is Record .... -- EXT_Length : Short_Integer; -- remove the field here; the discriminant itself is a field PRI_Per_Stagger : PRI_Stagger_Array(EXT_Length); End Record; then, once EXT_Length has a value, stored in a variable Lgth, say, you can declare declare This_Record: Intercept_Report(Ext_Length => Lgth); begin ... end; Give this a shot - see if it works. Mike Feldman ------------------------------------------------------------------------------- Michael B. Feldman Visiting Professor 1991-92 Professor Dept. of Comp. Sci. and Engrg. Dept. of Elect. Engrg. and Comp. Sci. University of Washington FR-35 The George Washington University Seattle, WA 98105 Washington, DC 20052 (206) 685-1376 (voice) (202) 994-5253 (voice) (206) 543-2969 (fax) (202) 994-5296 (fax) -------------------------------------------------------------------------------