comp.lang.ada
 help / color / mirror / Atom feed
From: "chris.danx" <chris.danx@ntlworld.com>
Subject: Re: explain error to me
Date: Thu, 5 Jul 2001 23:48:41 +0100
Date: 2001-07-05T23:48:41+01:00	[thread overview]
Message-ID: <08617.5643$Tv5.787326@news6-win.server.ntlworld.com> (raw)
In-Reply-To: tk9pumjsd3j8b3@corp.supernews.com


"Beau" <beau@hiwaay.net> wrote in message
news:tk9pumjsd3j8b3@corp.supernews.com...
> I am getting an error can someone help:
> the spec file as follows:

Beau,

I'm not bashing you, but could you please provide the error next time.  Like I
say it's not that i'm bashing you, it helps ppl help you, sometimes without the
need to compile your source.


I got this error
    "print_table.ads:23:28: invalid subtype mark in discrete range"

which refered to this line

TYPE HouseArrays IS ARRAY (ArraySize) OF HouseHolds;

Arraysize is defined like this

ArraySize : CONSTANT Positive := 25;


The error is due to the fact that ArraySize is not a range, but a constant.  25
is not the same as 1..25, so Ada rejects this.

You could do one of the following

1) declare HouseArrays like this

TYPE HouseArrays IS ARRAY (1..ArraySize) OF HouseHolds;

2) declare a type like this

-- a type representing the range of the number
-- of houses
SUBTYPE NumHouses is Natural range 1..25;

then declare houseArrays like this

TYPE HouseArrays IS ARRAY (NumHouses'first..NumHouses'last) OF HouseHolds;

3) Reuse ArrayCounter type as in 2.

TYPE HouseArrays IS ARRAY (ArrayCounter'first..ArrayCounter'last) OF HouseHolds;



I'm assuming that you've learned about attributes for 2 and 3.  In the computing
science course at glasgow uni, they taught this near the beginning when they
taught strings and string declarations.  This is why i'm assuming attributes, if
you don't know what they are stick with solution 1 and/or just ask and some one
here.  ( I know you like extra cred :-) )

Hope this helps,
Chris Campbell




  parent reply	other threads:[~2001-07-05 22:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-05 22:18 explain error to me Beau
2001-07-05 22:41 ` Don't read any more, I am an idiot. Fixed it myself Beau
2001-07-05 22:53   ` chris.danx
2001-07-05 22:48 ` chris.danx [this message]
2001-07-06  2:01   ` explain error to me Jeffrey Carter
replies disabled

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