From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,29f20adefa39a3a1,start X-Google-Attributes: gid103376,public From: oliver white Subject: Reply Quickly! Date: 1997/05/25 Message-ID: <3387E381.2389@opera.iinet.net.au> X-Deja-AN: 243765223 Organization: iiNet Technologies Pty Ltd Reply-To: ojw@opera.iinet.net.au Newsgroups: comp.lang.ada Date: 1997-05-25T00:00:00+00:00 List-Id: This is a multi-part message in MIME format. --------------7426375871CC Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit It is a simple problem, but could someone take a moment to help? I have written a program for my university assignment, but it seems to ignore a get_line in line 50 and the program jumps to the next loop, seemingly of the same structure, which functions normaly. Please reply in the next few hours :) Please explain in a manner easy for a man, new to ADA, to understand. Oliver --------------7426375871CC Content-Type: text/plain; charset=us-ascii; name="Vehical.adb" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="Vehical.adb" WITH Text_Io; PROCEDURE Vehical IS --Author: Oliver White --Date: 19/5/97 --This program is designed to take in data on a car's registration and --write it to a file for future referance SUBTYPE Yeartype IS Integer RANGE 1900..2100; TYPE Choice_Type IS (Register, Display, Help, Quit); PACKAGE Menu_Io IS NEW Text_Io.Enumeration_Io(Enum => Choice_Type); PACKAGE Boolean_Io IS NEW Text_Io.Enumeration_Io(Enum => Boolean); PACKAGE Int_Io IS NEW Text_Io.Integer_Io(Integer); PACKAGE Flo_Io IS NEW Text_Io.Float_Io(Float); RegNo : String(1..10); Name : String(1..30); Street : String(1..30); Suburb : String(1..20); IsCar : Boolean; Year : Yeartype; Price : Float; Menu_Choice : Choice_Type; Makefile : String(1..50); Output : Text_Io.File_Type; Input : Text_Io.File_Type; Last_RegNo : Natural; Last_Name : Natural; Last_Street : Natural; Last_Suburb : Natural; LastFile : Boolean := False; Last_Makefile : Natural; PROCEDURE Register IS --A subprogram to get data and write it to a file chosen by the user LastVehical : Boolean := False; BEGIN File_Loop: --loop until last file to be created LOOP MakeFile_Val_Loop: LOOP Text_Io.Put("Please enter name of file to be created:"); --get the file name Text_Io.New_Line; Text_Io.Put(">"); Text_Io.Get_Line(MakeFile, Last_MakeFile); MakeFile_Exception: BEGIN Text_Io.Create(Input, Text_Io.Out_File, MakeFile(1..Last_Makefile)); -- create file EXIT MakeFile_Val_Loop; EXCEPTION WHEN Text_Io.Name_Error => Text_Io.Put("Invalid file name"); END MakeFile_Exception; END LOOP MakeFile_Val_Loop; Vehical_Loop: -- loop untill last record to be entered in file LOOP RegNo_Val_Loop: LOOP RegNo_Exception: BEGIN Text_Io.Put("Please enter registration number:"); Text_Io.New_Line; Text_Io.Put(">"); Text_Io.Get_Line(RegNo, Last_RegNo); EXIT RegNo_Val_Loop; EXCEPTION WHEN Text_Io.Data_Error => Text_Io.Put("Wrong data type"); END RegNo_Exception; END LOOP RegNo_Val_Loop; Text_Io.Put(Input, RegNo (1..Last_RegNo)); Name_Val_Loop: LOOP Name_Exception: BEGIN Text_Io.Put("Please enter owner's name:"); Text_Io.New_Line; Text_Io.Put(">"); Text_Io.Get_Line(Name, Last_Name); EXIT Name_Val_Loop; EXCEPTION WHEN Text_Io.Data_Error => Text_Io.Put("Wrong data type"); END Name_Exception; END LOOP Name_Val_Loop; Text_Io.Put(Input, Name (1..Last_Name)); Street_Val_Loop: LOOP Street_Exception: BEGIN Text_Io.Put("Please enter owner's street name and number:"); Text_Io.New_Line; Text_Io.Put(">"); Text_Io.Get_Line(Street, Last_Street); EXIT Street_Val_Loop; EXCEPTION WHEN Text_Io.Data_Error => Text_Io.Put("Wrong data type"); END Street_Exception; END LOOP Street_Val_Loop; Text_Io.Put(Input, Street (1..Last_Street)); Suburb_Val_Loop: LOOP Suburb_Exception: BEGIN Text_Io.Put("Please enter owner's suburb:"); Text_Io.New_Line; Text_Io.Put(">"); Text_Io.Get_Line(Suburb, Last_Suburb); EXIT Suburb_Val_Loop; EXCEPTION WHEN Text_Io.Data_Error => Text_Io.Put("Wrong data type"); END Suburb_Exception; END LOOP Suburb_Val_Loop; Text_Io.Put(Input, Suburb (1..Last_Suburb)); IsCar_Val_Loop: LOOP IsCar_Exception: BEGIN Text_Io.Put("Vehical is car?"); Text_Io.New_Line; Text_Io.Put("Enter true or false."); Text_Io.New_Line; Text_Io.Put(">"); Boolean_Io.Get(IsCar); EXIT IsCar_Val_Loop; EXCEPTION WHEN Text_Io.Data_Error => Text_Io.Put("Wrong data type"); END IsCar_Exception; END LOOP IsCar_Val_Loop; Boolean_Io.Put(Input, IsCar); Year_Val_Loop: LOOP Year_Exception: BEGIN Text_Io.Put("Please enter Year of purchase in form XXXX:"); Text_Io.New_Line; Text_Io.Put(">"); Int_Io.Get(Year); EXIT Year_Val_Loop; EXCEPTION WHEN Text_Io.Data_Error => Text_Io.Put("Wrong data type"); END Year_Exception; END LOOP Year_Val_Loop; Int_Io.Put(Input, Year); Price_Val_Loop: LOOP Price_Exception: BEGIN Text_Io.Put("Please enter cost of car in A$:"); Text_Io.New_Line; Text_Io.Put(">"); Flo_Io.Get(Price); EXIT Price_Val_Loop; EXCEPTION WHEN Text_Io.Data_Error => Text_Io.Put("Wrong data type"); END Price_Exception; END LOOP Price_Val_Loop; Flo_Io.Put(Input, Price); LastVehical_Val_Loop: LOOP LastVehical_Exception: BEGIN Text_Io.Put("Was this the last vehical entry for this file?"); Text_Io.New_Line; Text_Io.Put("Enter true or false."); Text_Io.New_Line; Text_Io.Put(">"); Boolean_Io.Get(LastVehical); EXIT LastVehical_Val_Loop; EXCEPTION WHEN Text_Io.Data_Error => Text_Io.Put("Wrong data type"); END LastVehical_Exception; END LOOP LastVehical_Val_Loop; IF LastVehical = True THEN EXIT Vehical_Loop; END IF; END LOOP Vehical_Loop; Text_Io.Close(Input); LastFile_Val_Loop: LOOP LastFile_Exception: BEGIN Text_Io.Put("Was this the last file to be created?"); Text_Io.New_Line; Text_Io.Put("Enter true or false"); Text_Io.New_Line; Text_Io.Put(">"); Boolean_Io.Get(LastFile); EXIT LastFile_Val_Loop; EXCEPTION WHEN Text_Io.Data_Error => Text_Io.Put("Wrong data type"); END LastFile_Exception; END LOOP LastFile_Val_Loop; IF LastFile = True THEN EXIT File_Loop; END IF; END LOOP File_Loop; END Register; PROCEDURE Display IS --A procedure for displaying data previously written to a file NewCar : Natural := 0; Price_Total : Float := 0.0; Stop : String (1..1); Last_Stop : Natural; Countcar : Natural := 0; Ave_Price : Float; NextFile : Boolean; Current_Year : YearType := 1997; GetFile : String(1..50); Last_GetFile : Natural; BEGIN File_Loop: LOOP GetFile_Val_Loop: LOOP GetFile_Exception: BEGIN Text_Io.Put("Enter Filename:"); Text_Io.New_Line; Text_Io.Put(">"); Text_Io.Get_Line(GetFile, Last_GetFile); Text_Io.Open(Output, Text_Io.In_File, GetFile(1..Last_GetFile)); EXCEPTION WHEN Text_Io.Name_Error => Text_Io.Put("File does not exist"); END GetFile_Exception; END LOOP GetFile_Val_Loop; File_Read_Loop: LOOP EXIT File_Read_Loop WHEN Text_Io.End_Of_File(Input); Text_Io.Get_Line(RegNo, Last_RegNo); Text_Io.Get_Line(Name, Last_Name); Text_Io.Put(Name (1..Last_Name)); Text_Io.Skip_Line; Text_Io.New_Line; Text_Io.Get_Line(Suburb, Last_Suburb); Text_Io.Put(Suburb (1..Last_Suburb)); Text_Io.Skip_Line; Int_Io.Get(Year); IF Current_Year - Year < 10 THEN NewCar := NewCar + 1; END IF; Flo_Io.Get(Price); Price_Total := Price_Total + Price; Text_Io.Put("Press Enter to procede"); Text_Io.Get_Line(Stop, Last_Stop); Countcar := Countcar + 1; END LOOP File_Read_Loop; Text_Io.Put("Number of cars less than 10 yrs old: "); Int_Io.Put(Newcar); Text_Io.New_Line; Text_Io.Put("Average price of vehical: "); Ave_Price := Price_Total / Float(Countcar); Flo_Io.Put(Ave_Price); Text_Io.New_Line; NextFile_Val_Loop: LOOP NextFile_Exception: BEGIN Text_Io.Put("Would you like to look at another file?"); Text_Io.New_Line; Text_Io.Put("Please answer true or false"); Text_Io.New_Line; Text_Io.Put(">"); Boolean_Io.Get(NextFile); EXIT NextFile_Val_Loop; EXCEPTION WHEN Text_Io.Data_Error => Text_Io.Put("Wrong data type"); END NextFile_Exception; END LOOP NextFile_Val_Loop; IF NextFile = False THEN EXIT File_Loop; END IF; END LOOP File_Loop; END Display; BEGIN Main_Loop: LOOP Text_Io.Put("*************************"); Text_Io.New_Line; Text_Io.Put("* Menu *"); Text_Io.New_Line; Text_Io.Put("* Type HELP to get help *"); Text_Io.New_Line; Text_Io.Put("*************************"); Text_Io.New_Line; Choice_Loop: LOOP Choice_Exception: BEGIN Text_Io.Put(">"); Menu_Io.Get(Menu_Choice); --Choose task to perform EXIT Choice_Loop; EXCEPTION WHEN Text_Io.Data_Error => Text_Io.Put("Type HELP to learn comands"); END Choice_Exception; END LOOP Choice_Loop; IF Menu_Choice = Register THEN Register; ELSIF Menu_Choice = Display THEN Display; --ELSIF Menu_Choice = Help THEN --Help; ELSIF Menu_Choice = Quit THEN EXIT Main_Loop; END IF; END LOOP Main_Loop; END Vehical; --------------7426375871CC--