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.182.20.65 with SMTP id l1mr58908272obe.48.1417489078809; Mon, 01 Dec 2014 18:57:58 -0800 (PST) X-Received: by 10.140.29.230 with SMTP id b93mr365qgb.26.1417489078761; Mon, 01 Dec 2014 18:57:58 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!h15no3392086igd.0!news-out.google.com!m4ni576qag.1!nntp.google.com!w8no3988263qac.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Mon, 1 Dec 2014 18:57:58 -0800 (PST) In-Reply-To: <85iohvm2pp.fsf@stephe-leake.org> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=86.176.91.16; posting-account=pmkN8QoAAAAtIhXRUfydb0SCISnwaeyg NNTP-Posting-Host: 86.176.91.16 References: <0a70a8a3-45fc-440b-999b-f9cfbc6ac7f9@googlegroups.com> <8ecc1fb7-615c-4b7e-83e3-866a830a59a5@googlegroups.com> <47121b30-7fa8-4087-8bc9-d2099db7ea76@googlegroups.com> <85iohvm2pp.fsf@stephe-leake.org> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Help with an errant 'IF' statement please. From: Austin Obyrne Injection-Date: Tue, 02 Dec 2014 02:57:58 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 11801 X-Received-Body-CRC: 1924276759 Xref: news.eternal-september.org comp.lang.ada:23822 Date: 2014-12-01T18:57:58-08:00 List-Id: On Monday, December 1, 2014 10:20:52 PM UTC, Stephen Leake wrote: > Austin Obyrne writes: >=20 > >> Time_Ex_1; > >> Count :=3D Phi; --initialising change-of-origin Count >=20 > >=20 > 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: >=20 > 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 >=20 > Time_Ex_1; > Count :=3D Phi; --initialising change-of-origin Count > Resets :=3D 0; > Total :=3D 0; > NextChar :=3D ' '; --initialising to pre-empt error message > Line_Number:=3D 0; > LOOP > EXIT WHEN NextChar =3D Sentinel; > Count:=3D Count+1; -- change-of-origin count reinitia= lising > IF Count REM (Span + Phi +1) =3D 0 THEN -- Reset signal > Count:=3D 1; > Resets:=3D Resets +1; > END IF; > Total :=3D Total +1; > Ada.Text_IO.Get(Item =3D> NextChar); > Counter :=3D Counter +1; > Total :=3D Total +1; > Image(Counter):=3D NextChar; > -- FIXME: do _not_ include commented out code, unless it is part o= f the explanation of the problem >=20 > -- FIXME: most of this output is _not_ essential to show the bug; = delete them. > Ada.Text_IO.New_Line; > Ada.Text_IO.Put(Item =3D> " "); > Ada.Text_IO.Put(Item =3D> NextChar); > Ada.Text_IO.Put(Item =3D> " - Current PlainText for = encryption"); > Ada.Text_IO.New_Line; > Ada.Text_IO.Put(Item =3D> " "); > Ada.Text_IO.Put(Item =3D> " Phi "); > Ada.Text_IO.Put(Item =3D> " - "); > Ada.Integer_Text_IO.Put(Item =3D> Phi, Width =3D> 2); > Ada.Text_IO.New_Line; > Ada.Text_IO.Put(Item =3D> " "); > Ada.Text_IO.Put(Item =3D> " Count "); > Ada.Text_IO.Put(Item =3D> " - "); > Ada.Integer_Text_IO.Put(Item =3D> Count, Width =3D> 2); > Ada.Text_IO.New_Line; > Ada.Text_IO.Put(Item =3D> " "); > Ada.Text_IO.Put(Item =3D> " Total "); > Ada.Text_IO.Put(Item =3D> " - "); > Ada.Integer_Text_IO.Put(Item =3D> Total, Width =3D> 2); > Ada.Text_IO.New_line; > Ada.Integer_Text_IO.Put(Item =3D> Character'Pos(Nextchar), Width = =3D> 11); > Ada.Text_IO.Put > (Item =3D> " - Value in ASCII of current plaintext"= ); > Ada.Text_IO.New_line; > Compute_Normal; > Ada.Integer_Text_IO.Put(Item =3D> Normal(1), Width =3D> 4); > Ada.Integer_Text_IO.Put(Item =3D> Normal(2), Width =3D> 8); > Ada.Integer_Text_IO.Put(Item =3D> Normal(3), Width =3D> 8); > Ada.Text_IO.Put(Item =3D> " - Normal vector - fixed in this c= ipher"); > Ada.Text_IO.New_Line; > Ada.Integer_Text_IO.Put(Item =3D> S_1, Width =3D> 4); > Ada.Integer_Text_IO.Put(Item =3D> S_2, Width =3D> 8); > Ada.Integer_Text_IO.Put(Item =3D> S_3, Width =3D> 8); > Ada.Text_IO.Put > (Item =3D> " - VeeZero - fixed in this cipher"); > Ada.Text_IO.New_Line; > Ada.Integer_Text_IO.Put(Item =3D> T_1, Width =3D> 4); > Ada.Integer_Text_IO.Put(Item =3D> T_2, Width =3D> 8); > Ada.Integer_Text_IO.Put(Item =3D> T_3, Width =3D> 8); > Ada.Text_IO.Put > (Item =3D> " - VeeOne - fixed in this cipher."); > Ada.Text_IO.New_Line; > Compute_Normal; > Ada.Integer_Text_IO.Put(Item =3D> Normal(1), Width =3D> 4); > Ada.Integer_Text_IO.Put(Item =3D> Normal(2), Width =3D> 8); > Ada.Integer_Text_IO.Put(Item =3D> Normal(3), Width =3D> 8); > Ada.Text_IO.Put(Item =3D> " - Normal vector - fixed in this c= ipher"); > Ada.Text_IO.New_Line; > n :=3D(Character'Pos(NextChar)); > Ada.Integer_Text_IO.Put(Item =3D> n, Width =3D>12); > Ada.Text_IO.Put > (Item =3D> " - face value 'n' of current plaintext i= n ASCII"); > Ada.Text_IO.New_Line; > n :=3D Number(Character'Pos(NextChar)); -- renumbered by Alice > Ada.Integer_Text_IO.Put(Item =3D> n, Width =3D>12); > Ada.Text_IO.Put > (Item =3D> " - rendered value of 'n'in the encryptio= n alphabet"); > Compute_Position_Vector(Number =3D> n); > Ada.Text_IO.New_Line; > Ada.Integer_Text_IO.Put(Item =3D> Pn(1), Width =3D> 8); > Ada.Integer_Text_IO.Put(Item =3D> Pn(2), Width =3D> 8); > Ada.Integer_Text_IO.Put(Item =3D> Pn(3), Width =3D> 8); > Ada.Text_IO.Put(Item =3D> " - Position vector ('Pn') for this 'n'.= "); > Ada.Text_IO.New_Line; > Ada.Integer_Text_IO.Put(Item =3D> Hash_2(Count), Width =3D> 8); > Ada.Integer_Text_IO.Put(Item =3D> Hash_11(Count), Width =3D> 8); > Ada.Integer_Text_IO.Put(Item =3D> Hash_12(Count), Width =3D> 8); > Ada.Text_IO.Put > (Item =3D> " - Change-of-origin vector to be given to this Pn it= em"); > Ada.Text_IO.New_Line; > FOR I IN 1 .. 3 LOOP > W(I):=3D Compose_CipherText_Items( Numin =3D> I); > Ada.Integer_Text_IO.Put(File =3D> OutData, Item =3D> W(I)); > END LOOP; > Ada.Integer_Text_IO.Put( Item =3D> W(1), Width =3D> 9); > Ada.Integer_Text_IO.Put( Item =3D> W(2), Width =3D> 8); > Ada.Integer_Text_IO.Put( Item =3D> W(3), Width =3D> 8); > Ada.Text_IO.Put(Item =3D>" - Ciphertext for this item of plaintext"= ); > Q:=3D W(1)REM 1000000; > I_Num(Q) :=3D I_Num(Q)+1; > -- Q:=3D W(2)REM 1000000; > -- I_Num(Q) :=3D I_Num(Q)+1; > -- Q:=3D W(3)REM 1000000; > -- I_Num(Q) :=3D I_Num(Q)+1; > -- Ada.Text_IO.New_Line; > -- Ada.Integer_Text_IO.Put(Item =3D> AllTold, Width =3D>4); > -- Ada.Integer_Text_IO.Put(Item =3D> Total, Width =3D>8); > -- Ada.Integer_Text_IO.Put(Item =3D> InToto, Width =3D>8); > -- Ada.Text_IO.Put(Item =3D> " - Compares 'AllTold','Total','= InToto' integrators'"); > Line_Number:=3D Line_Number+1; > Ada.Text_IO.New_Line(1); > Ada.Text_IO.Put(Item =3D> " - Character nu= mber "); > Ada.Integer_Text_IO.Put(Item =3D> Line_Number, Width =3D> 1); > Ada.Text_IO.New_Line(1); > IF Line_Number REM 12 =3D 0 THEN > Ada.Text_IO.New_Line(1); > Ada.Text_IO.Put(Item =3D> " "); > Ada.Text_IO.Put(Item =3D> " # - press any key/return to continue= > "); > Ada.Text_IO.Get(Item =3D> View); > END IF; > Ada.Text_IO.New_Line; > Ada.Text_IO.Put(Item =3D> " --------------------------------------= -------------------------------------"); > END LOOP; > Ada.Text_IO.Close(File =3D> Outdata); > Time_Ex_2; -- time at end > end Obyrne_1; >=20 > This gives the following compilation errors: >=20 > 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 >=20 > Until these errors are fixed, we can't help you, because we can't tell > where the problem is. >=20 > See the FIXME: comments for more detailed advice on how to change the > code. >=20 > 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. >=20 > 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. >=20 > You could say something like: >=20 > I expect line 23 to output "23", but it outputs "42". >=20 > --=20 > -- Stephe Hi Stephe, I am overwhelmed with the volume of help from everybody. With hindsight I s= hould have taken more care in presenting my problem. Now that I know the dr= ill I will be more careful in the future. Part of my problem is in not lea= rning Ada properly. I go for problem solving by alternative methods instead= of fine tuning the method in hand. In passing, I note that professor M.B. Feldman is posting here also today. = I cannot overstate the email help this man gave me in getting stared with = Ada-95 - thanks again Professor - your book was and is excellent (if you ca= n get a used copy). adacrypt.