comp.lang.ada
 help / color / mirror / Atom feed
* Array problem
@ 2002-05-24 22:09 Andreas Lans
  2002-05-24 22:31 ` Preben Randhol
  2002-05-27 10:39 ` Alfred Hilscher
  0 siblings, 2 replies; 10+ messages in thread
From: Andreas Lans @ 2002-05-24 22:09 UTC (permalink / raw)


Thanks for all your help so far, I got the program working at least, but now
a runtime error has started to come up, and the thing its complaining about
is this:

if(pairs <= 100) then

Clients(Pairs) := new Male;

Servers(Pairs) := new Female;

Pairs := Pairs+1;



Where Pairs is an integer, I thought I could use this to store Females and
Males in the array but when I try this, it says: Illegal operand for array
conversion, any thoughts on this??








^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Array problem
  2002-05-24 22:09 Array problem Andreas Lans
@ 2002-05-24 22:31 ` Preben Randhol
  2002-05-25  8:49   ` Andreas Lans
  2002-05-25 11:30   ` Robert Dewar
  2002-05-27 10:39 ` Alfred Hilscher
  1 sibling, 2 replies; 10+ messages in thread
From: Preben Randhol @ 2002-05-24 22:31 UTC (permalink / raw)


On Fri, 24 May 2002 22:09:41 GMT, Andreas Lans wrote:
> Thanks for all your help so far, I got the program working at least, but now
> a runtime error has started to come up, and the thing its complaining about
> is this:
> 
> if(pairs <= 100) then
> 
> Clients(Pairs) := new Male;
> 
> Servers(Pairs) := new Female;
> 
> Pairs := Pairs+1;
> 
> 
> 
> Where Pairs is an integer, I thought I could use this to store Females and
> Males in the array but when I try this, it says: Illegal operand for array
> conversion, any thoughts on this??


if you look in the spec file (.ads) you see that the array is defined
from 1 .. 100 and your Pairs start with 0. This means you are trying to
access outside the bounds of the array. Either change the pairs
initiation to 1 or do:


Pairs := Pairs+1;
if(pairs <= 100) then
 Males (Pairs) := new Male;
 Females (Pairs) := new Female;
end if;

Now the program won't crash, but it won't do much either.

Preben



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Array problem
  2002-05-24 22:31 ` Preben Randhol
@ 2002-05-25  8:49   ` Andreas Lans
  2002-05-25 12:12     ` Preben Randhol
                       ` (2 more replies)
  2002-05-25 11:30   ` Robert Dewar
  1 sibling, 3 replies; 10+ messages in thread
From: Andreas Lans @ 2002-05-25  8:49 UTC (permalink / raw)




Well, I tried the thing you tipped me about, and I also tried just to put a
one in there just to see if it would work, but it still says Illegal operand
for array conversion, any thoughts on this?





"Preben Randhol" <randhol+abuse@pvv.org> skrev i meddelandet
news:slrnaetfpu.333.randhol+abuse@kiuk0156.chembio.ntnu.no...
> On Fri, 24 May 2002 22:09:41 GMT, Andreas Lans wrote:
> > Thanks for all your help so far, I got the program working at least, but
now
> > a runtime error has started to come up, and the thing its complaining
about
> > is this:
> >
> > if(pairs <= 100) then
> >
> > Clients(Pairs) := new Male;
> >
> > Servers(Pairs) := new Female;
> >
> > Pairs := Pairs+1;
> >
> >
> >
> > Where Pairs is an integer, I thought I could use this to store Females
and
> > Males in the array but when I try this, it says: Illegal operand for
array
> > conversion, any thoughts on this??
>
>
> if you look in the spec file (.ads) you see that the array is defined
> from 1 .. 100 and your Pairs start with 0. This means you are trying to
> access outside the bounds of the array. Either change the pairs
> initiation to 1 or do:
>
>
> Pairs := Pairs+1;
> if(pairs <= 100) then
>  Males (Pairs) := new Male;
>  Females (Pairs) := new Female;
> end if;
>
> Now the program won't crash, but it won't do much either.
>
> Preben





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Array problem
  2002-05-24 22:31 ` Preben Randhol
  2002-05-25  8:49   ` Andreas Lans
@ 2002-05-25 11:30   ` Robert Dewar
  1 sibling, 0 replies; 10+ messages in thread
From: Robert Dewar @ 2002-05-25 11:30 UTC (permalink / raw)


Preben Randhol <randhol+abuse@pvv.org> wrote in message news:<slrnaetfpu.333.randhol+abuse@kiuk0156.chembio.ntnu.no>...

I see a lot of posts recently where people are in my opinion
harming students by doing their homework for them. You would
be surprised how many students manage to do their assignments
by the following algorithm.

  {Write some rubbish approximation to the right code}

  while not ready to hand in yet do

    Ask someone for their help
    Get back improved code, and some helpful discussion
    Ignore the helpful discussion
    Replace old code with new improved code

  end loop;

And the result is that students can complete assignments knowing
nothing at all about what they are doing. The important learning
experience of an assignment comes from tackling problems yourself.

So I would urge those in CLA who want to be helpful to stick to
helpful discussions, and NOT to provide improved code or too
detailed an analysis of what the problem is.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Array problem
  2002-05-25  8:49   ` Andreas Lans
@ 2002-05-25 12:12     ` Preben Randhol
  2002-05-25 16:30     ` Robert Dewar
  2002-05-25 16:38     ` Robert Dewar
  2 siblings, 0 replies; 10+ messages in thread
From: Preben Randhol @ 2002-05-25 12:12 UTC (permalink / raw)


On Sat, 25 May 2002 08:49:34 GMT, Andreas Lans wrote:
> 
> 
> Well, I tried the thing you tipped me about, and I also tried just to put a
> one in there just to see if it would work, but it still says Illegal operand
> for array conversion, any thoughts on this?

Well it works for me. Perhaps time to start reading your textbook
instead now? You have a lot of other things to figure out in you
implementation.

Preben



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Array problem
  2002-05-25  8:49   ` Andreas Lans
  2002-05-25 12:12     ` Preben Randhol
@ 2002-05-25 16:30     ` Robert Dewar
  2002-05-25 18:00       ` Andreas Lans
  2002-05-25 16:38     ` Robert Dewar
  2 siblings, 1 reply; 10+ messages in thread
From: Robert Dewar @ 2002-05-25 16:30 UTC (permalink / raw)


"Andreas Lans" <b99andla@student.his.se> wrote in message news:<yeIH8.39886$n4.8879213@newsc.telia.net>...

> Well, I tried the thing you tipped me about, and I also tried just to put a
> one in there just to see if it would work, but it still says Illegal operand
> for array conversion, any thoughts on this?


Well we can certainly see the iteration in progress here
(perhaps if I ask for enough help enough times people will
write the entire program for me :-)

Andreas, the assignment is to figure this out for yourself!
Read about array conversions in your text book, or if you
can't find it there, go look up what an array conversion
is and you should be able to figure out the problem.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Array problem
  2002-05-25  8:49   ` Andreas Lans
  2002-05-25 12:12     ` Preben Randhol
  2002-05-25 16:30     ` Robert Dewar
@ 2002-05-25 16:38     ` Robert Dewar
  2 siblings, 0 replies; 10+ messages in thread
From: Robert Dewar @ 2002-05-25 16:38 UTC (permalink / raw)


"Andreas Lans" <b99andla@student.his.se> wrote in message news:<yeIH8.39886$n4.8879213@newsc.telia.net>...

> Well, I tried the thing you tipped me about, and I also 
> tried just to put a
> one in there just to see if it would work, but it still 
> says Illegal operand
> for array conversion, any thoughts on this?

If you see a message like this, approach it systematically.
There are two cases, either you intended an array conversion or you
did not intend it. Clearly the compiler
thinks you intended it.

Either way, you need to find out by reading your text book
what an array conversion looks like (not hard since it is
the same as any other type conversion). 

Now if you did not intend an array conversion, then figure
out what you did intend clearly, and look up how to achieve
it (if you guessed, you obviously guessed wrong).

If you DID intend an array conversion, then look up the
rules to see why this operand is not legal for an array
conversion.

That's the sort of way to approach figuring out something
like this on your own.

You may well find it helpful to run one of the online tutorials if you
are feeling generally confused by what
you are doing.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Array problem
  2002-05-25 16:30     ` Robert Dewar
@ 2002-05-25 18:00       ` Andreas Lans
  2002-05-26  9:09         ` Preben Randhol
  0 siblings, 1 reply; 10+ messages in thread
From: Andreas Lans @ 2002-05-25 18:00 UTC (permalink / raw)


Well, you can sit there and be smart and belittle my efforts to make this
work, but the fact is, and maybe you find me extremly stupid for saying
this, it certainly seems that youre making fun of me in this post, but I am
trying really hard, and I have searched everything before asking questions
on here. But I cant find anything. I still after your posts about what I
should look fore be able to make it work. So make fun of me and look down on
me if you will but dont tell me Im telling people to make my damn
assignments, I  just need help.



"Robert Dewar" <dewar@gnat.com> skrev i meddelandet
news:5ee5b646.0205250830.822e227@posting.google.com...
> "Andreas Lans" <b99andla@student.his.se> wrote in message
news:<yeIH8.39886$n4.8879213@newsc.telia.net>...
>
> > Well, I tried the thing you tipped me about, and I also tried just to
put a
> > one in there just to see if it would work, but it still says Illegal
operand
> > for array conversion, any thoughts on this?
>
>
> Well we can certainly see the iteration in progress here
> (perhaps if I ask for enough help enough times people will
> write the entire program for me :-)
>
> Andreas, the assignment is to figure this out for yourself!
> Read about array conversions in your text book, or if you
> can't find it there, go look up what an array conversion
> is and you should be able to figure out the problem.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Array problem
  2002-05-25 18:00       ` Andreas Lans
@ 2002-05-26  9:09         ` Preben Randhol
  0 siblings, 0 replies; 10+ messages in thread
From: Preben Randhol @ 2002-05-26  9:09 UTC (permalink / raw)


On Sat, 25 May 2002 18:00:34 GMT, Andreas Lans wrote:
> Well, you can sit there and be smart and belittle my efforts to make this
> work, but the fact is, and maybe you find me extremly stupid for saying
> this, it certainly seems that youre making fun of me in this post, but I am
> trying really hard, and I have searched everything before asking questions
> on here. But I cant find anything. I still after your posts about what I
> should look fore be able to make it work. So make fun of me and look down on
> me if you will but dont tell me Im telling people to make my damn
> assignments, I  just need help.

Nobody is making fun of you, but some of your questions are very basic. 

Preben



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Array problem
  2002-05-24 22:09 Array problem Andreas Lans
  2002-05-24 22:31 ` Preben Randhol
@ 2002-05-27 10:39 ` Alfred Hilscher
  1 sibling, 0 replies; 10+ messages in thread
From: Alfred Hilscher @ 2002-05-27 10:39 UTC (permalink / raw)


Hey Andreas,

Clients och Servers �r "type"s men f�r assignments du moste har en
variable. Klart nu? Se upp din code en g�ng till.

Andreas Lans wrote:
> 
> Thanks for all your help so far, I got the program working at least, but now
> a runtime error has started to come up, and the thing its complaining about
> is this:
> 
> if(pairs <= 100) then
> 
> Clients(Pairs) := new Male;
> 
> Servers(Pairs) := new Female;
> 
> Pairs := Pairs+1;
> 
> Where Pairs is an integer, I thought I could use this to store Females and
> Males in the array but when I try this, it says: Illegal operand for array
> conversion, any thoughts on this??



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2002-05-27 10:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-24 22:09 Array problem Andreas Lans
2002-05-24 22:31 ` Preben Randhol
2002-05-25  8:49   ` Andreas Lans
2002-05-25 12:12     ` Preben Randhol
2002-05-25 16:30     ` Robert Dewar
2002-05-25 18:00       ` Andreas Lans
2002-05-26  9:09         ` Preben Randhol
2002-05-25 16:38     ` Robert Dewar
2002-05-25 11:30   ` Robert Dewar
2002-05-27 10:39 ` Alfred Hilscher

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