* Help with an errant 'IF' statement please. @ 2014-11-29 13:28 Austin Obyrne 2014-11-29 14:03 ` gautier_niouzes 2014-11-29 14:08 ` Simon Clubley 0 siblings, 2 replies; 19+ messages in thread From: Austin Obyrne @ 2014-11-29 13:28 UTC (permalink / raw) A subset of a larger program is shown below. This is an IF statement that just won't work and the same has happened in the past on other occasions in this very same program alone while working ok in other parts of the same program further on as well as being ok in other loops. It works fine also in other programs in different loops but for some unknown (to me) reason it just won't work here in this loop on this occasion. I have tried everything to no avail. Maybe there is some basic syntax that I am contravening in this type of Loop. Your usual help would be greatly appreciated. The 'GET' function is intended to stall the run of the loop for viewing of the data. (Start looking here Please:) Line_Number : Integer; Sentinel : CONSTANT Character:= '~'; Line_Number:= 0; LOOP EXIT WHEN NextChar = Sentinel; 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 Total 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; ? Austin O' Byrne - aka adacrypt. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Help with an errant 'IF' statement please. 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 14:08 ` Simon Clubley 1 sibling, 1 reply; 19+ messages in thread From: gautier_niouzes @ 2014-11-29 14:03 UTC (permalink / raw) Le samedi 29 novembre 2014 14:28:40 UTC+1, Austin Obyrne a écrit : > This is an IF statement that just won't work and the same has happened in the past on other occasions in this very same program alone while working ok in other parts of the same program further on as well as being ok in other loops. Since Total doesn't change during the loop, the condition is either always True or always False. The IF works as always, but perhaps not in the way you expect... I guess you copy-pasted the IF statement from elsewhere, but then you should have "Line_Number" instead of "Total" to have a stop every 12 output lines. _________________________ Gautier's Ada programming http://gautiersblog.blogspot.com/search/label/Ada NB: follow the above link for a valid e-mail address ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Help with an errant 'IF' statement please. 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:54 ` Dennis Lee Bieber 0 siblings, 2 replies; 19+ messages in thread From: Austin Obyrne @ 2014-11-29 15:05 UTC (permalink / raw) On Saturday, November 29, 2014 2:03:26 PM UTC, gautier...@hotmail.com wrote: > Le samedi 29 novembre 2014 14:28:40 UTC+1, Austin Obyrne a écrit : > > > This is an IF statement that just won't work and the same has happened in the past on other occasions in this very same program alone while working ok in other parts of the same program further on as well as being ok in other loops. > > Since Total doesn't change during the loop, the condition is either always True or always False. The IF works as always, but perhaps not in the way you expect... I guess you copy-pasted the IF statement from elsewhere, but then you should have "Line_Number" instead of "Total" to have a stop every 12 output lines. > _________________________ > Gautier's Ada programming > http://gautiersblog.blogspot.com/search/label/Ada > NB: follow the above link for a valid e-mail address I beg your pardon. Total should not be there - it remained from my last experiment. This is what I should have posted :- Start here|: Line_Number : Integer; Sentinel : CONSTANT Character:= '~'; Line_Number:= 0; LOOP EXIT WHEN NextChar = Sentinel; 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; Sorry for confusing matters, please continue if you will - Austin ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Help with an errant 'IF' statement please. 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 1 sibling, 1 reply; 19+ messages in thread From: Simon Clubley @ 2014-11-29 15:45 UTC (permalink / raw) On 2014-11-29, Austin Obyrne <austin.obyrne@hotmail.com> wrote: > > Sorry for confusing matters, please continue if you will - Austin Reduce the problem to a complete, compilable, test case program and explain what the specific problem is with the test case you have posted. I've seen what happens too many times when people post fragments of a program instead of a complete standalone test case - and quite a bit of the time the act of generating the test case results in the OP finding the real problem. There are at least a couple of issues in the second fragment - turn it into a standalone program and you should find them. Simon. -- Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP Microsoft: Bringing you 1980s technology to a 21st century world ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Help with an errant 'IF' statement please. 2014-11-29 15:45 ` Simon Clubley @ 2014-11-29 16:10 ` Austin Obyrne 0 siblings, 0 replies; 19+ messages in thread From: Austin Obyrne @ 2014-11-29 16:10 UTC (permalink / raw) On Saturday, November 29, 2014 3:45:34 PM UTC, Simon Clubley wrote: > On 2014-11-29, Austin Obyrne <austin.obyrne@hotmail.com> wrote: > > > > Sorry for confusing matters, please continue if you will - Austin > > Reduce the problem to a complete, compilable, test case program and > explain what the specific problem is with the test case you have posted. > > I've seen what happens too many times when people post fragments of a > program instead of a complete standalone test case - and quite a bit of > the time the act of generating the test case results in the OP finding > the real problem. > > There are at least a couple of issues in the second fragment - turn > it into a standalone program and you should find them. > > Simon. > > -- > Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP > Microsoft: Bringing you 1980s technology to a 21st century world Thanks Simon, I'll try that - one of the doubts in my mind is that this program that I am designing is an interactive program that 'gets' inputs from the key board in an email encryption program and is not reading the plaintext characters from an external batch file as I usually do. I am assuming that the computer stores these inputs in a holding buffer of some kind from whence it later encrypts the lot in one fell swoop. I suspect this may be a breeding ground for 'bugs' (unheard of up to now in about 15 years of usage). I will keep trying, Many thanks for your kind help to everyone - Austin. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Help with an errant 'IF' statement please. 2014-11-29 15:05 ` Austin Obyrne 2014-11-29 15:45 ` Simon Clubley @ 2014-11-29 16:54 ` Dennis Lee Bieber 2014-11-30 2:16 ` Austin Obyrne 1 sibling, 1 reply; 19+ messages in thread From: Dennis Lee Bieber @ 2014-11-29 16:54 UTC (permalink / raw) On Sat, 29 Nov 2014 07:05:09 -0800 (PST), Austin Obyrne <austin.obyrne@hotmail.com> declaimed the following: >LOOP > EXIT WHEN NextChar = Sentinel; > What is the definition of "NextChar", since I don't see it changing inside this loop... -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/ ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Help with an errant 'IF' statement please. 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 11:56 ` Denis McMahon 0 siblings, 2 replies; 19+ messages in thread From: Austin Obyrne @ 2014-11-30 2:16 UTC (permalink / raw) On Saturday, November 29, 2014 4:53:48 PM UTC, Dennis Lee Bieber wrote: > On Sat, 29 Nov 2014 07:05:09 -0800 (PST), Austin Obyrne > <austin.obyrne@hotmail.com> declaimed the following: > > > >LOOP > > EXIT WHEN NextChar = Sentinel; > > > What is the definition of "NextChar", since I don't see it changing > inside this loop... > > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/ This is the relevant source code at the very start of the program in question, Total := Total+1; Ada.Text_IO.Get(Item => NextChar); Image(Total):= NextChar; 'NextChar' is the variable name given to each character being read in from the keyboard. This program is giving so much trouble that I don't think it is worth continuing any further with it as an *interactive email tool - alternatively, an email message that is prepared in an editor is just as convenient and is far more robust for reading in and encrypting just as I would with say any batch file. *I have made an experimental change to an algorithm that worked very well before the change but all this has inexplicably come along with the change. I have never felt comfortable with this interactive process even when it worked well and will stop using it altogether now - it isn't cost effective to persevere with it any further especially when it is suspect. An encrypted message travels as an attachment to an unsecured covering email(for the present) - there is no advantage in encrypting it in interactive mode compared with preparing it in an editor like say 'Notepad' - all my instincts say I am doing something wrong. Sorry for taking so long in coming back and thanks for your help - Austin. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Help with an errant 'IF' statement please. 2014-11-30 2:16 ` Austin Obyrne @ 2014-11-30 11:18 ` Simon Clubley 2014-11-30 12:58 ` Austin Obyrne 2014-11-30 11:56 ` Denis McMahon 1 sibling, 1 reply; 19+ messages in thread From: Simon Clubley @ 2014-11-30 11:18 UTC (permalink / raw) On 2014-11-30, Austin Obyrne <austin.obyrne@hotmail.com> wrote: > On Saturday, November 29, 2014 4:53:48 PM UTC, Dennis Lee Bieber wrote: >> On Sat, 29 Nov 2014 07:05:09 -0800 (PST), Austin Obyrne >> <austin.obyrne@hotmail.com> declaimed the following: >> >> >> >LOOP >> > EXIT WHEN NextChar = Sentinel; >> > >> What is the definition of "NextChar", since I don't see it changing >> inside this loop... >> > > This is the relevant source code at the very start of the program in > question, > > Total := Total+1; > Ada.Text_IO.Get(Item => NextChar); > Image(Total):= NextChar; > > 'NextChar' is the variable name given to each character being read > in from the keyboard. > [snip] > Sorry for taking so long in coming back and thanks for your help - Austin. Do what I told you to do and write a stripped down standalone test program around the fragment you posted. You will then see what Dennis (and myself) are telling you. I could tell you what the problem is, but I think it's more important for you to understand how to find this yourself. Simon. -- Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP Microsoft: Bringing you 1980s technology to a 21st century world ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Help with an errant 'IF' statement please. 2014-11-30 11:18 ` Simon Clubley @ 2014-11-30 12:58 ` Austin Obyrne 2014-11-30 13:01 ` Austin Obyrne 2014-11-30 13:46 ` Simon Clubley 0 siblings, 2 replies; 19+ messages in thread From: Austin Obyrne @ 2014-11-30 12:58 UTC (permalink / raw) On Sunday, November 30, 2014 11:18:33 AM UTC, Simon Clubley wrote: > On 2014-11-30, Austin Obyrne <austin.obyrne@hotmail.com> wrote: > > On Saturday, November 29, 2014 4:53:48 PM UTC, Dennis Lee Bieber wrote: > >> On Sat, 29 Nov 2014 07:05:09 -0800 (PST), Austin Obyrne > >> <austin.obyrne@hotmail.com> declaimed the following: > >> > >> > >> >LOOP > >> > EXIT WHEN NextChar = Sentinel; > >> > > >> What is the definition of "NextChar", since I don't see it changing > >> inside this loop... > >> > > > > This is the relevant source code at the very start of the program in > > question, > > > > Total := Total+1; > > Ada.Text_IO.Get(Item => NextChar); > > Image(Total):= NextChar; > > > > 'NextChar' is the variable name given to each character being read > > in from the keyboard. > > > > [snip] > > > Sorry for taking so long in coming back and thanks for your help - Austin. > > Do what I told you to do and write a stripped down standalone test program > around the fragment you posted. > > You will then see what Dennis (and myself) are telling you. > > I could tell you what the problem is, but I think it's more important for > you to understand how to find this yourself. > > Simon. > > -- > Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP > Microsoft: Bringing you 1980s technology to a 21st century world Hi Simon - herewith the program sourcecode of the procedure in question - I would like to know for future - my main preoccupation is with problem solving but the elegance and efficacy of Ada are important to me also - bear with me -this a an experimental program by me and is not a fine example of programming in Ada. I would appreciate your help - I am going flat out with research work in cryptoland - Ada is a tool to me at the moment until I get more time to 'smell the flowers' of the language proper. 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; -- R := Character 'POS(NextChar); -- PlainTextNum(R) := PlainTextNum(R) +1; 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; -- IF W(2)REM 1000000 = 514681 THEN --repeated number in ciphertext say -- Ada.Integer_Text_IO.Put (item => W(2) , Width => 20); -- 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 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Help with an errant 'IF' statement please. 2014-11-30 12:58 ` Austin Obyrne @ 2014-11-30 13:01 ` Austin Obyrne 2014-12-01 22:20 ` Stephen Leake 2014-11-30 13:46 ` Simon Clubley 1 sibling, 1 reply; 19+ messages in thread From: Austin Obyrne @ 2014-11-30 13:01 UTC (permalink / raw) On Sunday, November 30, 2014 12:58:34 PM UTC, Austin Obyrne wrote: > On Sunday, November 30, 2014 11:18:33 AM UTC, Simon Clubley wrote: > > On 2014-11-30, Austin Obyrne <austin.obyrne@hotmail.com> wrote: > > > On Saturday, November 29, 2014 4:53:48 PM UTC, Dennis Lee Bieber wrote: > > >> On Sat, 29 Nov 2014 07:05:09 -0800 (PST), Austin Obyrne > > >> <austin.obyrne@hotmail.com> declaimed the following: > > >> > > >> > > >> >LOOP > > >> > EXIT WHEN NextChar = Sentinel; > > >> > > > >> What is the definition of "NextChar", since I don't see it changing > > >> inside this loop... > > >> > > > > > > This is the relevant source code at the very start of the program in > > > question, > > > > > > Total := Total+1; > > > Ada.Text_IO.Get(Item => NextChar); > > > Image(Total):= NextChar; > > > > > > 'NextChar' is the variable name given to each character being read > > > in from the keyboard. > > > > > > > [snip] > > > > > Sorry for taking so long in coming back and thanks for your help - Austin. > > > > Do what I told you to do and write a stripped down standalone test program > > around the fragment you posted. > > > > You will then see what Dennis (and myself) are telling you. > > > > I could tell you what the problem is, but I think it's more important for > > you to understand how to find this yourself. > > > > Simon. > > > > -- > > Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP > > Microsoft: Bringing you 1980s technology to a 21st century world > > Hi Simon - herewith the program sourcecode of the procedure in question - I would like to know for future - my main preoccupation is with problem solving but the elegance and efficacy of Ada are important to me also - bear with me -this a an experimental program by me and is not a fine example of programming in Ada. I would appreciate your help - I am going flat out with research work in cryptoland - Ada is a tool to me at the moment until I get more time to 'smell the flowers' of the language proper. > > 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; > -- R := Character 'POS(NextChar); > -- PlainTextNum(R) := PlainTextNum(R) +1; > 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; > -- IF W(2)REM 1000000 = 514681 THEN --repeated number in ciphertext say > -- Ada.Integer_Text_IO.Put (item => W(2) , Width => 20); > -- 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 Their is some experimental debris in there also I'm afraid - apologies for that. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Help with an errant 'IF' statement please. 2014-11-30 13:01 ` Austin Obyrne @ 2014-12-01 22:20 ` Stephen Leake 2014-12-02 2:57 ` Austin Obyrne 0 siblings, 1 reply; 19+ messages in thread From: Stephen Leake @ 2014-12-01 22:20 UTC (permalink / raw) 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 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Help with an errant 'IF' statement please. 2014-12-01 22:20 ` Stephen Leake @ 2014-12-02 2:57 ` Austin Obyrne 0 siblings, 0 replies; 19+ messages in thread From: Austin Obyrne @ 2014-12-02 2:57 UTC (permalink / raw) 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. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Help with an errant 'IF' statement please. 2014-11-30 12:58 ` Austin Obyrne 2014-11-30 13:01 ` Austin Obyrne @ 2014-11-30 13:46 ` Simon Clubley 2014-11-30 14:49 ` Austin Obyrne 1 sibling, 1 reply; 19+ messages in thread From: Simon Clubley @ 2014-11-30 13:46 UTC (permalink / raw) On 2014-11-30, Austin Obyrne <austin.obyrne@hotmail.com> wrote: > On Sunday, November 30, 2014 11:18:33 AM UTC, Simon Clubley wrote: >> >> Do what I told you to do and write a stripped down standalone test program >> around the fragment you posted. >> >> You will then see what Dennis (and myself) are telling you. >> >> I could tell you what the problem is, but I think it's more important for >> you to understand how to find this yourself. >> > > Hi Simon - herewith the program sourcecode of the procedure in > question - I would like to know for future - my main preoccupation is > with problem solving but the elegance and efficacy of Ada are > important to me also - bear with me -this a an experimental program by > me and is not a fine example of programming in Ada. I would appreciate > your help - I am going flat out with research work in cryptoland - Ada > is a tool to me at the moment until I get more time to 'smell the > flowers' of the language proper. > Hello Austin, I said a standalone, compilable, test version. The idea is that you post a small standalone example of your code which can be directly copied from the posting into a file and then compiled on a person's system. You also need to reduce the code to the minimum necessary to demonstrate the problem. BTW, it is during this reduction process that the reason for the problem has a habit of becoming clear. :-) Along with posting the code, you also state the _specific_ problem you are having with this code (doesn't exit a loop, doesn't add up correctly, etc) along with the output you are seeing. Only at this point do we have enough information to try and help you. For example, in the code you have posted, there are no variable definitions, there are functions (such as Time_Ex_1) which are used and not defined and you have not stated what the specific problem is with this version of the code. BTW, I'm not being difficult here, I'm trying to get you to help yourself by explaining what is needed before you can be given some suggestions. The process you need to go through here is the exact same process we all go through when trying to isolate some specific problem. To everyone else: Austin doesn't seem to understand what I am asking him to do. Could my comments be improved in some way ? Thanks, Simon. -- Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP Microsoft: Bringing you 1980s technology to a 21st century world ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Help with an errant 'IF' statement please. 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 0 siblings, 2 replies; 19+ messages in thread From: Austin Obyrne @ 2014-11-30 14:49 UTC (permalink / raw) On Sunday, November 30, 2014 1:46:58 PM UTC, Simon Clubley wrote: > On 2014-11-30, Austin Obyrne <austin.obyrne@hotmail.com> wrote: > > On Sunday, November 30, 2014 11:18:33 AM UTC, Simon Clubley wrote: > >> > >> Do what I told you to do and write a stripped down standalone test program > >> around the fragment you posted. > >> > >> You will then see what Dennis (and myself) are telling you. > >> > >> I could tell you what the problem is, but I think it's more important for > >> you to understand how to find this yourself. > >> > > > > Hi Simon - herewith the program sourcecode of the procedure in > > question - I would like to know for future - my main preoccupation is > > with problem solving but the elegance and efficacy of Ada are > > important to me also - bear with me -this a an experimental program by > > me and is not a fine example of programming in Ada. I would appreciate > > your help - I am going flat out with research work in cryptoland - Ada > > is a tool to me at the moment until I get more time to 'smell the > > flowers' of the language proper. > > > > Hello Austin, > > I said a standalone, compilable, test version. > > The idea is that you post a small standalone example of your code which > can be directly copied from the posting into a file and then compiled > on a person's system. > > You also need to reduce the code to the minimum necessary to demonstrate > the problem. BTW, it is during this reduction process that the reason for > the problem has a habit of becoming clear. :-) > > Along with posting the code, you also state the _specific_ problem you > are having with this code (doesn't exit a loop, doesn't add up correctly, > etc) along with the output you are seeing. > > Only at this point do we have enough information to try and help you. > > For example, in the code you have posted, there are no variable definitions, > there are functions (such as Time_Ex_1) which are used and not defined and > you have not stated what the specific problem is with this version of the > code. > > BTW, I'm not being difficult here, I'm trying to get you to help yourself > by explaining what is needed before you can be given some suggestions. > > The process you need to go through here is the exact same process we all > go through when trying to isolate some specific problem. > > To everyone else: Austin doesn't seem to understand what I am asking him > to do. Could my comments be improved in some way ? > > Thanks, > > Simon. > > -- > Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP > Microsoft: Bringing you 1980s technology to a 21st century world Thanks a million again. This is the only program in several hundred where this method of stalling the program does not work and it is only when I used this type of loop i.e. being terminated by a 'sentinel' character that it happens. It is not a problem in the current cipher now but I have taken on board your advice for future - I do understand what I must do sometime soon in the future and I may have to come back to you again - you are saying I should create some innocuous program and try stalling it by the same means and the reason why it won't work should surface - I hadn't thought of that. I will be doing that asap. Thanks for your much appreciated help - am I right in my intentions?. I have scrapped the program in hand but I need to know for future in other programs. - I think I've got you right ! - Austin ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Help with an errant 'IF' statement please. 2014-11-30 14:49 ` Austin Obyrne @ 2014-11-30 15:43 ` Simon Clubley 2014-11-30 19:23 ` Shark8 1 sibling, 0 replies; 19+ messages in thread From: Simon Clubley @ 2014-11-30 15:43 UTC (permalink / raw) On 2014-11-30, Austin Obyrne <austin.obyrne@hotmail.com> wrote: > > This is the only program in several hundred where this method of > stalling the program does not work and it is only when I used this > type of loop i.e. being terminated by a 'sentinel' character that it > happens. It is not a problem in the current cipher now but I have > taken on board your advice for future - I do understand what I must do > sometime soon in the future and I may have to come back to you again - > you are saying I should create some innocuous program and try stalling > it by the same means and the reason why it won't work should surface - > I hadn't thought of that. I will be doing that asap. > > Thanks for your much appreciated help - am I right in my intentions?. > In your test program, you need to use a copy of the _actual_ small section of the code which is giving you trouble instead of re-creating it from the ground up as the purpose is to explore what the problem code is _actually_ doing instead of what you _think_ it is doing. You also need to make sure there are no variables defined which are not needed by the faulty section of code and then you look at what variables are actually needed by the faulty code as it currently stands to see if that also gives you any clues. Once you have duplicated the problem in your small test program, you can then start reducing the code further until the problem either becomes clear to you or it becomes something which you can post for further help. If you have a debugger to hand (such as gdb) you can also step through the faulty code using the debugger and examining variables and program flow as the code executes. Simon. -- Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP Microsoft: Bringing you 1980s technology to a 21st century world ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Help with an errant 'IF' statement please. 2014-11-30 14:49 ` Austin Obyrne 2014-11-30 15:43 ` Simon Clubley @ 2014-11-30 19:23 ` Shark8 1 sibling, 0 replies; 19+ messages in thread From: Shark8 @ 2014-11-30 19:23 UTC (permalink / raw) On 30-Nov-14 07:49, Austin Obyrne wrote: > Thanks for your much appreciated help - am I right in my intentions?. That's really hard to say; any particular construct/usage might be doable but that doesn't mean that it's even good. -- In the case of looping there's perfectly rational cases for a sentinel-value (namely unconstrained input, user input in particular), but that doesn't mean that's the best way to do it: Streams, for example, write the bounds and then the data for items like arrays (which works because when you write those items out the constraints are known). So, we really cannot tell w/o a small compilable example, and explanation of your intent, like Simon said. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Help with an errant 'IF' statement please. 2014-11-30 2:16 ` Austin Obyrne 2014-11-30 11:18 ` Simon Clubley @ 2014-11-30 11:56 ` Denis McMahon 2014-11-30 12:19 ` Austin Obyrne 1 sibling, 1 reply; 19+ messages in thread From: Denis McMahon @ 2014-11-30 11:56 UTC (permalink / raw) On Sat, 29 Nov 2014 18:16:35 -0800, Austin Obyrne wrote: > This is the relevant source code at the very start of the program in > question, > > Total := Total+1; Ada.Text_IO.Get(Item => NextChar); > Image(Total):= NextChar; Yes, but when you post that in isolation, we have no idea where to place it in the code you originally posted. When you say "at the very start" do you mean before the LOOP is declared, or do you mean inside the loop after the exit condition is declared, or do you mean inside the loop before the exit condition is declared, or something else? We're guessing. What's Image? Is it relevant to reproducing the problem? What about all the IO? How much of that is your troubleshooting, and how much is actually relevant to the problem? Please help us to help you! -- Denis McMahon, denismfmcmahon@gmail.com ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Help with an errant 'IF' statement please. 2014-11-30 11:56 ` Denis McMahon @ 2014-11-30 12:19 ` Austin Obyrne 0 siblings, 0 replies; 19+ messages in thread From: Austin Obyrne @ 2014-11-30 12:19 UTC (permalink / raw) On Sunday, November 30, 2014 11:56:46 AM UTC, Denis McMahon wrote: > On Sat, 29 Nov 2014 18:16:35 -0800, Austin Obyrne wrote: > > > This is the relevant source code at the very start of the program in > > question, > > > > Total := Total+1; Ada.Text_IO.Get(Item => NextChar); > > Image(Total):= NextChar; > > Yes, but when you post that in isolation, we have no idea where to place > it in the code you originally posted. > > When you say "at the very start" do you mean before the LOOP is declared, > or do you mean inside the loop after the exit condition is declared, or > do you mean inside the loop before the exit condition is declared, or > something else? > > We're guessing. > > What's Image? Is it relevant to reproducing the problem? What about all > the IO? How much of that is your troubleshooting, and how much is > actually relevant to the problem? > > Please help us to help you! > > -- > Denis McMahon, denismfmcmahon@gmail.com At the risk of sounding ungrateful I have decided that this whole idea of interactive encryption may be causing mayhem within the computer register - true or false it is not worth continuing - it is much better I realise now to simply prepare an email program in an editor and read it in for encryption rather than key it in from the keyboard - that was not going to any big deal anyway and was obviouslt shaky. I rewrote the whole program again this morning and it behaved just the same when I tested it. Many thanks for your kind help again. - Austin ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Help with an errant 'IF' statement please. 2014-11-29 13:28 Help with an errant 'IF' statement please Austin Obyrne 2014-11-29 14:03 ` gautier_niouzes @ 2014-11-29 14:08 ` Simon Clubley 1 sibling, 0 replies; 19+ messages in thread From: Simon Clubley @ 2014-11-29 14:08 UTC (permalink / raw) On 2014-11-29, Austin Obyrne <austin.obyrne@hotmail.com> wrote: > > Maybe there is some basic syntax that I am contravening in this type of Loop. > > Your usual help would be greatly appreciated. > The problem appears to be so obvious you caused me to do a text search for "Total" while I was composing this reply in emacs in case I was missing something and posted something dumb. :-) Question for you: where exactly is Total incremented within your loop ? Simon. -- Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP Microsoft: Bringing you 1980s technology to a 21st century world ^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2014-12-02 2:57 UTC | newest] Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 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 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox