comp.lang.ada
 help / color / mirror / Atom feed
From: "Josh Highley" <joshhighley@hotmail.com>
Subject: Maybe not exactly a variant record.
Date: 1999/04/22
Date: 1999-04-22T19:32:07+00:00	[thread overview]
Message-ID: <371f1e6d.0@silver.truman.edu> (raw)
In-Reply-To: 371c84fb.0@silver.truman.edu


Josh Highley <joshhighley@hotmail.com> wrote in message
news:371c84fb.0@silver.truman.edu...
> I have the following type declaration and I would like to have an array of
> them.  However, I need "length" to have different values for each element
of
> the array.
>
> type field (length : positive) is limited private;
> --it's later defined to be a record with a string(1..length), among other
> information.
>
> For instance, I would like field_array(1) to be a field with a length of
10,
> field_array(2) to be a field of length 50, and so on.  Can I declare an
> array of these fields, with each field of a different length?
>
> I'm using GNAT 3.11, AdaGIDE 6.21, and Win95

I guess I should clarify.  I'm not exactly sure the record is variant, at
least not in the sense as some people have thought.  So, here's the private
declaration of "type field(length : positive);"

private
    type field (length : positive ) is record
         row            : y_pos := 0;
         column       : x_pos := 0;
         fld_length   : positive := length;
         text            : string(1..length) := (others => ' ');
         text_length  : natural := 0;
         label           : string(1..x_pos'last) := (others => ' ');
         label_length : natural := 0;
         align           : alignment := left;
         char           : character := ' ';
         position      : natural := 0;
    end record;

I know there's a lot of room for optimization, but it gets the job done : )

So, the value of "length" doesn't change the record fields that are
accessible, just the number of characters in a string.  Now that I've better
described the situation, does this change the responses to declaring an
array of type field with different lengths??

P.S.  For my future reference, is the record that I've declared above
considered a variant record, or is it called something else since the
available record fields don't actually change with the value of "length"?

Thanks again,

Josh Highley
joshhighley@hotmail.com






  parent reply	other threads:[~1999-04-22  0:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-04-20  0:00 Can I have an array of variant records? Josh Highley
1999-04-20  0:00 ` bglbv
1999-04-21  0:00   ` Robert Dewar
1999-04-21  0:00     ` Pawel Kobylarz
1999-04-21  0:00       ` David C. Hoos, Sr.
1999-04-21  0:00         ` Robert Dewar
1999-04-21  0:00       ` dennison
1999-04-21  0:00         ` Robert Dewar
1999-04-22  0:00           ` Josh Highley
1999-04-23  0:00           ` Pawel Kobylarz
1999-04-21  0:00       ` czgrr
1999-04-21  0:00     ` bglbv
1999-04-22  0:00       ` dennison
1999-04-21  0:00 ` Robert Dewar
1999-04-22  0:00 ` Josh Highley [this message]
1999-04-22  0:00   ` Maybe not exactly a variant record dennison
1999-04-23  0:00     ` Nick Roberts
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox