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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.50.79.197 with SMTP id l5mr6329113igx.0.1394404745912; Sun, 09 Mar 2014 15:39:05 -0700 (PDT) X-Received: by 10.140.101.171 with SMTP id u40mr544012qge.1.1394404745876; Sun, 09 Mar 2014 15:39:05 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!ur14no4754728igb.0!news-out.google.com!du2ni1227qab.0!nntp.google.com!w5no2921114qac.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 9 Mar 2014 15:39:05 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=188.115.2.128; posting-account=sDyr7QoAAAA7hiaifqt-gaKY2K7OZ8RQ NNTP-Posting-Host: 188.115.2.128 References: <9b780534-04fb-43c8-b8de-1610421c471d@googlegroups.com> <3b08719c-e689-4170-9c1c-3f9250030dd6@googlegroups.com> <5c2fbc70-26cc-4656-b18e-7e2c0251e3c9@googlegroups.com> <1k2kd9jvh59hm$.fvcqzozu55g7.dlg@40tude.net> <1c0ut34zkn6ik.ozor88pk1lyl.dlg@40tude.net> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Reading data from file From: Laurent Injection-Date: Sun, 09 Mar 2014 22:39:05 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Received-Bytes: 7249 X-Received-Body-CRC: 300026871 Xref: news.eternal-september.org comp.lang.ada:18799 Date: 2014-03-09T15:39:05-07:00 List-Id: Hi I have a quite strange error/behavior of my code which I don't understand (the error): if this Debugging_Enabled : Boolean := True; then the procedure below reads the 3 records from my text file. 2 are inserted into the database, the 3rd is not because same ID as the 1st. If Debugging_Enabled : Boolean := False; then only the 1st record is read. Same txt file. I have localized the error: if Debugging_Enabled then Ada.Text_IO.Put_Line ("Database Manager: read file loop"); Ada.Text_IO.Put_Line ("Status: End of file: " & Boolean'Image (End_Of_File)); Ada.Text_IO.Put_Line ("Status: End of record: " & Boolean'Image (End_Of_Record)); Ada.Text_IO.Put_Line ("Successfully integrated: " & Natural'Image (Successful_Integration)); Ada.Text_IO.Put_Line ("Failed integration(s) :" & Natural'Image (Failed_Integration)); Ada.Text_IO.New_Line; end if; If this is executed everything is fine. I had commented out everything except Ada.Text_IO.New_Line; and the it worked. With just a null statement it fails.?! No idea what is wrong. I don't see why this happens. https://github.com/Chutulu/Chapter-11.git Is the database_manager.adb Will not compile because the screen.ads/adb is missing. just needs to be commented out. Thanks Laurent /snip declare End_Of_Record : Boolean := False; -- Import_File is not empty End_Of_File : Boolean := False; -- Import_File is not empty Debugging_Enabled : Boolean := True; -- hope we don't need this Import_File : Ada.Text_IO.File_Type; Successful_Integration : Natural := 0; Failed_Integration : Natural := 0; Record_Counter : Natural := 0; begin -- declare -- open the file and associate it with the file variable name Ada.Text_IO.Open (File => Import_File, Mode => Ada.Text_IO.In_File, Name => "Datafile.txt"); Read_From_File : loop Screen.ClearScreen; Screen.MoveCursor (Row => 3, Column => 5); Ada.Text_IO.Put_Line ("Read data from file"); Ada.Text_IO.New_Line; Read_File : loop if Debugging_Enabled then Ada.Text_IO.Put_Line ("Database Manager: read file loop"); Ada.Text_IO.Put_Line ("Status: End of file: " & Boolean'Image (End_Of_File)); Ada.Text_IO.Put_Line ("Status: End of record: " & Boolean'Image (End_Of_Record)); Ada.Text_IO.Put_Line ("Successfully integrated: " & Natural'Image (Successful_Integration)); Ada.Text_IO.Put_Line ("Failed integration(s) :" & Natural'Image (Failed_Integration)); Ada.Text_IO.New_Line; end if; exit when End_Of_File; Read_Record : loop --if Debugging_Enabled then --Ada.Text_IO.Put_Line ("Database Manager: read record loop"); --Ada.Text_IO.Put_Line ("Status: End of file: " & Boolean'Image (End_Of_File)); --Ada.Text_IO.Put_Line ("Status: End of record: " & Boolean'Image (End_Of_Record)); --Ada.Text_IO.Put_Line ("Successfully integrated: " & Natural'Image (Successful_Integration)); --Ada.Text_IO.Put_Line ("Failed integration(s) :" & Natural'Image (Failed_Integration)); --Ada.Text_IO.New_Line; --end if; Employees.IO.Read_Employee_From_File (File => Import_File, Item => E, End_Of_Record => End_Of_Record, EOF => End_Of_File); if not End_Of_Record then Database.Insert (E => E, Success => Success); Record_Counter := Record_Counter + 1; if Success then Successful_Integration := Successful_Integration + 1; else Failed_Integration := Failed_Integration + 1; Ada.Text_IO.Put_Line("Record failed to be read:" & Natural'Image(Record_Counter)); end if; end if; exit when End_Of_Record; end loop Read_Record; end loop Read_File; Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line ("Succesfully integrated:" & Natural'Image(Successful_Integration)); Ada.Text_IO.Put_Line ("Failed integration(s):" & Natural'Image (Failed_Integration)); Ada.Text_IO.Put_Line("Total number of records in file:" & Natural'Image(Record_Counter)); Ada.Text_IO.New_Line; Ada.Text_IO.Put (Item => "Enter Q to go back to main menu: "); Command_IO.Get (Item => MenuSelection); exit when MenuSelection = Q; Ada.Text_IO.New_Line; end loop Read_From_File; end; -- declare Read_From_File snip/