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 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.236.103.164 with SMTP id f24mr58185369yhg.11.1417472451910; Mon, 01 Dec 2014 14:20:51 -0800 (PST) Path: border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!w8no3953223qac.0!news-out.google.com!n9ni1qai.0!nntp.google.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!news.flashnewsgroups.com-b7.4zTQh5tI3A!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Help with an errant 'IF' statement please. References: <0a70a8a3-45fc-440b-999b-f9cfbc6ac7f9@googlegroups.com> <8ecc1fb7-615c-4b7e-83e3-866a830a59a5@googlegroups.com> <47121b30-7fa8-4087-8bc9-d2099db7ea76@googlegroups.com> Date: Mon, 01 Dec 2014 16:20:50 -0600 Message-ID: <85iohvm2pp.fsf@stephe-leake.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.94 (windows-nt) Cancel-Lock: sha1:OMcRPDCjGID90XvKRDW3dCtvEhg= MIME-Version: 1.0 X-Complaints-To: abuse@flashnewsgroups.com Organization: FlashNewsgroups.com X-Trace: d9cc8547ce9c3e3fb833019141 X-Received-Bytes: 9880 X-Received-Body-CRC: 3114633341 Content-Type: text/plain Xref: number.nntp.giganews.com comp.lang.ada:191121 Date: 2014-12-01T16:20:50-06:00 List-Id: Austin Obyrne writes: >> Time_Ex_1; >> Count := Phi; --initialising change-of-origin Count In order to help you understand what you need to change in this post so we can help, I've attempted to make this compile. Here's a modified version, with some fixes, and some FIXME: comments: with Ada.Text_IO; procedure Obyrne_1 is -- FIXME: put all required definitions here, as reported by the -- compilation errors: Time_Ex_1, Count, Phi, Resets, Total, n, -- Number, NextChar, Line_Number, Sentinel, Span, Counter, Image, -- Compose_CipherText_Items, Q, I_Num, Time_Ex_2 -- -- While you are doing that, delete any that are not needed to -- show the problem. begin Time_Ex_1; Count := Phi; --initialising change-of-origin Count Resets := 0; Total := 0; NextChar := ' '; --initialising to pre-empt error message Line_Number:= 0; LOOP EXIT WHEN NextChar = Sentinel; Count:= Count+1; -- change-of-origin count reinitialising IF Count REM (Span + Phi +1) = 0 THEN -- Reset signal Count:= 1; Resets:= Resets +1; END IF; Total := Total +1; Ada.Text_IO.Get(Item => NextChar); Counter := Counter +1; Total := Total +1; Image(Counter):= NextChar; -- FIXME: do _not_ include commented out code, unless it is part of the explanation of the problem -- FIXME: most of this output is _not_ essential to show the bug; delete them. Ada.Text_IO.New_Line; Ada.Text_IO.Put(Item => " "); Ada.Text_IO.Put(Item => NextChar); Ada.Text_IO.Put(Item => " - Current PlainText for encryption"); Ada.Text_IO.New_Line; Ada.Text_IO.Put(Item => " "); Ada.Text_IO.Put(Item => " Phi "); Ada.Text_IO.Put(Item => " - "); Ada.Integer_Text_IO.Put(Item => Phi, Width => 2); Ada.Text_IO.New_Line; Ada.Text_IO.Put(Item => " "); Ada.Text_IO.Put(Item => " Count "); Ada.Text_IO.Put(Item => " - "); Ada.Integer_Text_IO.Put(Item => Count, Width => 2); Ada.Text_IO.New_Line; Ada.Text_IO.Put(Item => " "); Ada.Text_IO.Put(Item => " Total "); Ada.Text_IO.Put(Item => " - "); Ada.Integer_Text_IO.Put(Item => Total, Width => 2); Ada.Text_IO.New_line; Ada.Integer_Text_IO.Put(Item => Character'Pos(Nextchar), Width => 11); Ada.Text_IO.Put (Item => " - Value in ASCII of current plaintext"); Ada.Text_IO.New_line; Compute_Normal; Ada.Integer_Text_IO.Put(Item => Normal(1), Width => 4); Ada.Integer_Text_IO.Put(Item => Normal(2), Width => 8); Ada.Integer_Text_IO.Put(Item => Normal(3), Width => 8); Ada.Text_IO.Put(Item => " - Normal vector - fixed in this cipher"); Ada.Text_IO.New_Line; Ada.Integer_Text_IO.Put(Item => S_1, Width => 4); Ada.Integer_Text_IO.Put(Item => S_2, Width => 8); Ada.Integer_Text_IO.Put(Item => S_3, Width => 8); Ada.Text_IO.Put (Item => " - VeeZero - fixed in this cipher"); Ada.Text_IO.New_Line; Ada.Integer_Text_IO.Put(Item => T_1, Width => 4); Ada.Integer_Text_IO.Put(Item => T_2, Width => 8); Ada.Integer_Text_IO.Put(Item => T_3, Width => 8); Ada.Text_IO.Put (Item => " - VeeOne - fixed in this cipher."); Ada.Text_IO.New_Line; Compute_Normal; Ada.Integer_Text_IO.Put(Item => Normal(1), Width => 4); Ada.Integer_Text_IO.Put(Item => Normal(2), Width => 8); Ada.Integer_Text_IO.Put(Item => Normal(3), Width => 8); Ada.Text_IO.Put(Item => " - Normal vector - fixed in this cipher"); Ada.Text_IO.New_Line; n :=(Character'Pos(NextChar)); Ada.Integer_Text_IO.Put(Item => n, Width =>12); Ada.Text_IO.Put (Item => " - face value 'n' of current plaintext in ASCII"); Ada.Text_IO.New_Line; n := Number(Character'Pos(NextChar)); -- renumbered by Alice Ada.Integer_Text_IO.Put(Item => n, Width =>12); Ada.Text_IO.Put (Item => " - rendered value of 'n'in the encryption alphabet"); Compute_Position_Vector(Number => n); Ada.Text_IO.New_Line; Ada.Integer_Text_IO.Put(Item => Pn(1), Width => 8); Ada.Integer_Text_IO.Put(Item => Pn(2), Width => 8); Ada.Integer_Text_IO.Put(Item => Pn(3), Width => 8); Ada.Text_IO.Put(Item => " - Position vector ('Pn') for this 'n'. "); Ada.Text_IO.New_Line; Ada.Integer_Text_IO.Put(Item => Hash_2(Count), Width => 8); Ada.Integer_Text_IO.Put(Item => Hash_11(Count), Width => 8); Ada.Integer_Text_IO.Put(Item => Hash_12(Count), Width => 8); Ada.Text_IO.Put (Item => " - Change-of-origin vector to be given to this Pn item"); Ada.Text_IO.New_Line; FOR I IN 1 .. 3 LOOP W(I):= Compose_CipherText_Items( Numin => I); Ada.Integer_Text_IO.Put(File => OutData, Item => W(I)); END LOOP; Ada.Integer_Text_IO.Put( Item => W(1), Width => 9); Ada.Integer_Text_IO.Put( Item => W(2), Width => 8); Ada.Integer_Text_IO.Put( Item => W(3), Width => 8); Ada.Text_IO.Put(Item =>" - Ciphertext for this item of plaintext"); Q:= W(1)REM 1000000; I_Num(Q) := I_Num(Q)+1; -- Q:= W(2)REM 1000000; -- I_Num(Q) := I_Num(Q)+1; -- Q:= W(3)REM 1000000; -- I_Num(Q) := I_Num(Q)+1; -- Ada.Text_IO.New_Line; -- Ada.Integer_Text_IO.Put(Item => AllTold, Width =>4); -- Ada.Integer_Text_IO.Put(Item => Total, Width =>8); -- Ada.Integer_Text_IO.Put(Item => InToto, Width =>8); -- Ada.Text_IO.Put(Item => " - Compares 'AllTold','Total','InToto' integrators'"); Line_Number:= Line_Number+1; Ada.Text_IO.New_Line(1); Ada.Text_IO.Put(Item => " - Character number "); Ada.Integer_Text_IO.Put(Item => Line_Number, Width => 1); Ada.Text_IO.New_Line(1); IF Line_Number REM 12 = 0 THEN Ada.Text_IO.New_Line(1); Ada.Text_IO.Put(Item => " "); Ada.Text_IO.Put(Item => " # - press any key/return to continue > "); Ada.Text_IO.Get(Item => View); END IF; Ada.Text_IO.New_Line; Ada.Text_IO.Put(Item => " ---------------------------------------------------------------------------"); END LOOP; Ada.Text_IO.Close(File => Outdata); Time_Ex_2; -- time at end end Obyrne_1; This gives the following compilation errors: obyrne_1.adb:6:04: "Time_Ex_1" is undefined obyrne_1.adb:7:04: "Count" is undefined (more references follow) obyrne_1.adb:7:14: "Phi" is undefined (more references follow) obyrne_1.adb:8:04: "Resets" is undefined (more references follow) obyrne_1.adb:9:04: "Total" is undefined (more references follow) obyrne_1.adb:10:04: "NextChar" is undefined (more references follow) obyrne_1.adb:11:04: "Line_Number" is undefined (more references follow) obyrne_1.adb:13:28: "Sentinel" is undefined obyrne_1.adb:15:21: "Span" is undefined obyrne_1.adb:20:07: "Ada" is undefined (more references follow) obyrne_1.adb:20:07: missing "with Ada.Text_IO;" obyrne_1.adb:21:18: "Counter" is undefined (more references follow) obyrne_1.adb:23:07: "Image" is undefined obyrne_1.adb:51:07: "Compute_Normal" is undefined (more references follow) obyrne_1.adb:75:07: "n" is undefined (more references follow) obyrne_1.adb:80:12: "Number" is undefined obyrne_1.adb:84:07: "Compute_Position_Vector" is undefined obyrne_1.adb:98:10: "W" is undefined (more references follow) obyrne_1.adb:98:17: "Compose_CipherText_Items" is undefined obyrne_1.adb:105:07: "Q" is undefined (more references follow) obyrne_1.adb:106:19: "I_Num" is undefined (more references follow) obyrne_1.adb:131:04: "Time_Ex_2" is undefined Until these errors are fixed, we can't help you, because we can't tell where the problem is. See the FIXME: comments for more detailed advice on how to change the code. Your first post said there was an "if" statement that did not work, so the code you present should contain just that "if" statment, together with the required declarations, and some Text_IO.Put_lines to demonstrate the problem. In addition, please state clearly what the problem is. The only thing you've said so far is "it doesn't work". That usually means "it doesn't do what I want it to do". Since we don't know what you want it to do, we can't help. You could say something like: I expect line 23 to output "23", but it outputs "42". -- -- Stephe