* Contraint error
@ 1998-10-11 0:00 Renwick Preston
1998-10-11 0:00 ` Matthew Heaney
1998-10-11 0:00 ` Tucker Taft
0 siblings, 2 replies; 7+ messages in thread
From: Renwick Preston @ 1998-10-11 0:00 UTC (permalink / raw)
My program just started creating a constraint error after I added some Boolean variables
with code that used those variables. I'm thinking that the way I'm using them is what is
causing the problem.
I first initialize them all to False. In my program I have a case statement with some code for
each case. Here is a snippet:
case Month
when June
If June_Completed then <- Line added
< some code here>
June_Completed := True; <- Line added
End if; <- Line added
<more code>
end case;
Everything worked fine until I added the lines marked.
What could be the problem?
Ren
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Contraint error
1998-10-11 0:00 Contraint error Renwick Preston
1998-10-11 0:00 ` Matthew Heaney
@ 1998-10-11 0:00 ` Tucker Taft
1 sibling, 0 replies; 7+ messages in thread
From: Tucker Taft @ 1998-10-11 0:00 UTC (permalink / raw)
Renwick Preston (rpreston@phoenix.net) wrote:
: My program just started creating a constraint error after I added some Boolean variables
: with code that used those variables. I'm thinking that the way I'm using them is what is
: causing the problem.
: I first initialize them all to False. In my program I have a case statement with some code for
: each case. Here is a snippet:
: case Month
: when June
: If June_Completed then <- Line added
: < some code here>
: June_Completed := True; <- Line added
: End if; <- Line added
: <more code>
: end case;
: Everything worked fine until I added the lines marked.
: What could be the problem?
The added lines look a bit suspicious, since you are setting "June_Completed"
to True only if it is already True (your indenting leaves a bit to
be desired ;-).
In any case, to really diagnose this problem, the reader
will need a complete but minimal test case which shows the problem.
A "snippet" will rarely be enough for someone to figure out what is
going wrong.
: Ren
--
-Tucker Taft stt@inmet.com http://www.inmet.com/~stt/
Intermetrics, Inc. Burlington, MA USA
An AverStar Company
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Contraint error
1998-10-11 0:00 Contraint error Renwick Preston
@ 1998-10-11 0:00 ` Matthew Heaney
1998-10-11 0:00 ` Renwick Preston
1998-10-11 0:00 ` Renwick Preston
1998-10-11 0:00 ` Tucker Taft
1 sibling, 2 replies; 7+ messages in thread
From: Matthew Heaney @ 1998-10-11 0:00 UTC (permalink / raw)
Renwick Preston <rpreston@phoenix.net> writes:
You'll have to provide more source code. There's nothing in the
fragment you did provide that would indicate CE gets raised.
Is June_Completed a subtype? Do you do this:
declare
June_Completed : Boolean range False .. False := False;
begin
...
June_Completed := True;
...
end;
Of course, this really would raise CE.
You're not using a debugger?
Are you using a compiler that supports display of Exception_Information?
> My program just started creating a constraint error after I added some
> Boolean variables with code that used those variables. I'm thinking
> that the way I'm using them is what is causing the problem.
>
> I first initialize them all to False. In my program I have a case
> statement with some code for each case. Here is a snippet:
>
> case Month
> when June
> If June_Completed then <- Line added
> < some code here>
> June_Completed := True; <- Line added
> End if; <- Line added
> <more code>
> end case;
>
> Everything worked fine until I added the lines marked.
>
> What could be the problem?
>
> Ren
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Contraint error
1998-10-11 0:00 ` Matthew Heaney
@ 1998-10-11 0:00 ` Renwick Preston
1998-10-11 0:00 ` Tom Moran
1998-10-11 0:00 ` Matthew Heaney
1998-10-11 0:00 ` Renwick Preston
1 sibling, 2 replies; 7+ messages in thread
From: Renwick Preston @ 1998-10-11 0:00 UTC (permalink / raw)
I'm using the compiler that came with the book Ada 95 Problem Solving and Program Design. Actually the code should have read
If NOT June_Completed etc but I fixed the problem by adding
When Others
NULL;
at the end of the CASE statement. I don't understand why that fixed it because all the
possible cases were already covered.
Thanks,
Ren
Matthew Heaney wrote:
> Renwick Preston <rpreston@phoenix.net> writes:
>
> You'll have to provide more source code. There's nothing in the
> fragment you did provide that would indicate CE gets raised.
>
> Is June_Completed a subtype? Do you do this:
>
> declare
> June_Completed : Boolean range False .. False := False;
> begin
> ...
> June_Completed := True;
> ...
> end;
>
> Of course, this really would raise CE.
>
> You're not using a debugger?
>
> Are you using a compiler that supports display of Exception_Information?
>
> > My program just started creating a constraint error after I added some
> > Boolean variables with code that used those variables. I'm thinking
> > that the way I'm using them is what is causing the problem.
> >
> > I first initialize them all to False. In my program I have a case
> > statement with some code for each case. Here is a snippet:
> >
> > case Month
> > when June
> > If June_Completed then <- Line added
> > < some code here>
> > June_Completed := True; <- Line added
> > End if; <- Line added
> > <more code>
> > end case;
> >
> > Everything worked fine until I added the lines marked.
> >
> > What could be the problem?
> >
> > Ren
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Contraint error
1998-10-11 0:00 ` Matthew Heaney
1998-10-11 0:00 ` Renwick Preston
@ 1998-10-11 0:00 ` Renwick Preston
1 sibling, 0 replies; 7+ messages in thread
From: Renwick Preston @ 1998-10-11 0:00 UTC (permalink / raw)
I forgot to say that June_Completed was declared as a plain old Boolean.
Ren
Matthew Heaney wrote:
> Renwick Preston <rpreston@phoenix.net> writes:
>
> You'll have to provide more source code. There's nothing in the
> fragment you did provide that would indicate CE gets raised.
>
> Is June_Completed a subtype? Do you do this:
>
> declare
> June_Completed : Boolean range False .. False := False;
> begin
> ...
> June_Completed := True;
> ...
> end;
>
> Of course, this really would raise CE.
>
> You're not using a debugger?
>
> Are you using a compiler that supports display of Exception_Information?
>
> > My program just started creating a constraint error after I added some
> > Boolean variables with code that used those variables. I'm thinking
> > that the way I'm using them is what is causing the problem.
> >
> > I first initialize them all to False. In my program I have a case
> > statement with some code for each case. Here is a snippet:
> >
> > case Month
> > when June
> > If June_Completed then <- Line added
> > < some code here>
> > June_Completed := True; <- Line added
> > End if; <- Line added
> > <more code>
> > end case;
> >
> > Everything worked fine until I added the lines marked.
> >
> > What could be the problem?
> >
> > Ren
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Contraint error
1998-10-11 0:00 ` Renwick Preston
1998-10-11 0:00 ` Tom Moran
@ 1998-10-11 0:00 ` Matthew Heaney
1 sibling, 0 replies; 7+ messages in thread
From: Matthew Heaney @ 1998-10-11 0:00 UTC (permalink / raw)
Renwick Preston <rpreston@phoenix.net> writes:
> I'm using the compiler that came with the book Ada 95 Problem Solving
> and Program Design. Actually the code should have read
>
> If NOT June_Completed etc but I fixed the problem by adding
>
> When Others
> NULL;
>
> at the end of the CASE statement. I don't understand why that fixed it
> because all the possible cases were already covered.
Was the Month object given a value? It could be that you tried to
execute a case statement using an object that wasn't initialized, and
you were lucky enough to get an exception.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Contraint error
1998-10-11 0:00 ` Renwick Preston
@ 1998-10-11 0:00 ` Tom Moran
1998-10-11 0:00 ` Matthew Heaney
1 sibling, 0 replies; 7+ messages in thread
From: Tom Moran @ 1998-10-11 0:00 UTC (permalink / raw)
>When Others
> NULL;
>at the end of the CASE statement. I don't understand why that fixed it because all the
>possible cases were already covered.
I doubt it. How is Month declared? What is the complete When
structure of the Case statement? Check *very* carefully and I'll bet
you find that June, and whatever other 'when' values you didn't show
us, are not the only possible values of Month.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~1998-10-11 0:00 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-11 0:00 Contraint error Renwick Preston
1998-10-11 0:00 ` Matthew Heaney
1998-10-11 0:00 ` Renwick Preston
1998-10-11 0:00 ` Tom Moran
1998-10-11 0:00 ` Matthew Heaney
1998-10-11 0:00 ` Renwick Preston
1998-10-11 0:00 ` Tucker Taft
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox