From: Austin Obyrne <austin.obyrne@hotmail.com>
Subject: Re: Help with an errant 'IF' statement please.
Date: Mon, 1 Dec 2014 18:57:58 -0800 (PST)
Date: 2014-12-01T18:57:58-08:00 [thread overview]
Message-ID: <f94c6a14-4f64-477b-91ad-09498c2c2ae9@googlegroups.com> (raw)
In-Reply-To: <85iohvm2pp.fsf@stephe-leake.org>
On Monday, December 1, 2014 10:20:52 PM UTC, Stephen Leake wrote:
> Austin Obyrne <austin.obyrne@hotmail.com> writes:
>
> >> Time_Ex_1;
> >> Count := Phi; --initialising change-of-origin Count
>
> <snip>
>
> 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
Hi Stephe,
I am overwhelmed with the volume of help from everybody. With hindsight I should have taken more care in presenting my problem. Now that I know the drill I will be more careful in the future. Part of my problem is in not learning 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 can get a used copy).
adacrypt.
next prev parent reply other threads:[~2014-12-02 2:57 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-29 13:28 Help with an errant 'IF' statement please Austin Obyrne
2014-11-29 14:03 ` gautier_niouzes
2014-11-29 15:05 ` Austin Obyrne
2014-11-29 15:45 ` Simon Clubley
2014-11-29 16:10 ` Austin Obyrne
2014-11-29 16:54 ` Dennis Lee Bieber
2014-11-30 2:16 ` Austin Obyrne
2014-11-30 11:18 ` Simon Clubley
2014-11-30 12:58 ` Austin Obyrne
2014-11-30 13:01 ` Austin Obyrne
2014-12-01 22:20 ` Stephen Leake
2014-12-02 2:57 ` Austin Obyrne [this message]
2014-11-30 13:46 ` Simon Clubley
2014-11-30 14:49 ` Austin Obyrne
2014-11-30 15:43 ` Simon Clubley
2014-11-30 19:23 ` Shark8
2014-11-30 11:56 ` Denis McMahon
2014-11-30 12:19 ` Austin Obyrne
2014-11-29 14:08 ` Simon Clubley
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox