Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ada: loop is causing later code to be unreachable

Tags:

ada

I'm new to Ada. I'm trying to get the following code to work:

begin
Ada.Text_IO.Put_Line("Student ID Score");
Ada.Text_IO.Put_Line("===================");
readAnswers(pAnswers, 1);

loop
declare
   counter : Integer := 0;
   studentInput : String := Get_Line(Input);
   studentScore : Integer;
begin
   numOfTests := numOfTests + 1;
   current_student.ID := GetID(studentInput);
   Ada.Text_IO.Put(Ada.Strings.Unbounded.To_String(current_student.ID));
   readAnswers(studentInput (6 .. studentInput'Last) ,0);
   studentScore := scoreTest(current_student.student_answer, current_answer_key, number_of_questions);
      Ada.Integer_Text_IO.Put(studentScore);
      New_Line(1);
end;
end loop;

Ada.Text_IO.Put_Line("===================");
Ada.Text_IO.Put("Tests Graded = ");
Ada.Integer_Text_IO.Put(numOfTests);
end;

Unfortunately, GNAT tells me that all the code after the loop is unreachable. How can I get this program to execute the loop and the code after it?

like image 929
Connor Flanagan Avatar asked Dec 17 '22 14:12

Connor Flanagan


1 Answers

You forget the exit condition :

loop
  exit when condition;
end loop;
like image 163
XAMT Avatar answered Feb 01 '23 10:02

XAMT