Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Array declaration problem

Array declaration problem

Array declaration problem


I started to learn ADA, and got some array problems. The error message is "unconstrained element type in array declaration" ( yes, I found a topic like this, but I could not really understand it ).

My task would be: In a package-> To make a farm (a record), it contains animals ( another record ) and an array called animals, I should put the animals into an array, but i can't really figure out, how can I define it to be constrained...

Can someone whisper me, how could I fix it?
I wrote variable names in Hungarian ( because its easyer, but I will translate it, if it is finished ).
So. I translated the main part of the program ( the others are negligible in the view of fixing ).

package baromfiudvar is

    type Farm_Animals is (chicken, Rabbit, Goose, Beef, Pig, Horse); - --negligible...
    subtype Own_range is Integer range 1..100;  --saját range a nem def.-ált range miatt

    type Animal (AnimalType : Farm_Animals) is record
        AType : Farm_Animals := AnimalType;
        Suly : Float := 0.0; --adott állat súlya
                Lakohely : String(1..100); --lakóhely, disznóól, istálló, stb
                Labak_szama : Positive := 2;
                Repule : Boolean := false;
                Napi_ar : Float := 0.0;
                Napi_szorzo : Float := 0.0;

                        case AnimalType is
                                when Tyuk => Napi_tojasok_szama : Natural;
                                when Nyul => Szaporulatok_szama : Natural;
                                when Kecske => KTej : Natural;
                                when Marha => MTej : Natural;
                                when Diszno => Napi_hizas : Float;
                                when Lo => Teherbiras : Positive; --KGban
                        end case;
        end record;

    type Farm ( Max : Positive ) is limited private;

    type Animals is array (Own_range range<> ) of Animal; --Állatokat tartalmazó tömb
    type Farm ( Max : Positive ) is record --UDVAR
                Data : Animals(1..Max); --Az udvarban lévő állatok tömbje
             Act : Natural := 1;
             Size : Natural := Max; --mondjuk S.Max elég...
    end record;

end baromfiudvar;

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close