On 4/25/2013 2:38 PM, kpie...@gmail.com wrote:unsuccessful as well.
I am trying to use nested if statements in Cobol. As far as I can tell I am following the style guides, but keep receiving the error:
file_name.cob:64: Error: syntax error, unexpected ELSE
^ This is the second ELSE statement
The purpose of the code is to function as a Caesar cipher, but it seems to only be the nested if statements that are producing the error. I tried putting the nested statements after the ELSE clause of the initial IF statement, but that was
Thank you too sir. I had same issue, looking around for hours how to sort it out!I am using open-cobol, and and compiling with the '-free' option on the 1.1 compiler
IF CharCount < 26
ADD firstnum, CharCount GIVING stringShift.
DISPLAY stringShift.
IF FUNCTION MOD(stringShift, 26) IS NOT ZERO
MOVE FUNCTION MOD(stringShift, 26) to stringShift
DISPLAY stringShift
MOVE abc(stringShift:stringShift) TO newChar
DISPLAY newChar
STRING newString DELIMITED BY "", newChar DELIMITED BY SIZE INTO newString
DISPLAY newString
ELSE
STRING newString DELIMITED BY "", searchChar DELIMITED BY SIZE INTO newString
DISPLAY newString
END-IF
ELSE
STRING newString DELIMITED BY "", searchChar DELIMITED BY SIZE INTO newString
DISPLAY newString
END-IF.
Note: I know this is a beginner question, but have looked at a lot of documentation and am at a loss.
Thanks!
Assuming you pasted the code verbatim in your example, the periods in
the two statements immediately after "IF CharCount < 26" are part of the problem... If you are using END-IF scope delimiters, do NOT use periods
at the end of any statement except the last statement in a paragraph!
The period at the end of "ADD firstnum, CharCount GIVING stringShift." terminates the IF - not at all what you intended.
HTH
On Thursday, 25 April 2013 at 20:00:23 UTC+1, Kerry Liles wrote:unsuccessful as well.
On 4/25/2013 2:38 PM, kpie...@gmail.com wrote:
I am trying to use nested if statements in Cobol. As far as I can tell I am following the style guides, but keep receiving the error:
file_name.cob:64: Error: syntax error, unexpected ELSE
^ This is the second ELSE statement
The purpose of the code is to function as a Caesar cipher, but it seems to only be the nested if statements that are producing the error. I tried putting the nested statements after the ELSE clause of the initial IF statement, but that was
Thank you too sir. I had same issue, looking around for hours how to sort it out!Assuming you pasted the code verbatim in your example, the periods in
I am using open-cobol, and and compiling with the '-free' option on the 1.1 compiler
IF CharCount < 26
ADD firstnum, CharCount GIVING stringShift.
DISPLAY stringShift.
IF FUNCTION MOD(stringShift, 26) IS NOT ZERO
MOVE FUNCTION MOD(stringShift, 26) to stringShift
DISPLAY stringShift
MOVE abc(stringShift:stringShift) TO newChar
DISPLAY newChar
STRING newString DELIMITED BY "", newChar DELIMITED BY SIZE INTO newString >>>
DISPLAY newString
ELSE
STRING newString DELIMITED BY "", searchChar DELIMITED BY SIZE INTO newString
DISPLAY newString
END-IF
ELSE
STRING newString DELIMITED BY "", searchChar DELIMITED BY SIZE INTO newString
DISPLAY newString
END-IF.
Note: I know this is a beginner question, but have looked at a lot of documentation and am at a loss.
Thanks!
the two statements immediately after "IF CharCount < 26" are part of the
problem... If you are using END-IF scope delimiters, do NOT use periods
at the end of any statement except the last statement in a paragraph!
The period at the end of "ADD firstnum, CharCount GIVING stringShift."
terminates the IF - not at all what you intended.
HTH
On 11/3/2021 7:46 AM, Tony Ennis wrote:unsuccessful as well.
On Thursday, 25 April 2013 at 20:00:23 UTC+1, Kerry Liles wrote:
On 4/25/2013 2:38 PM, kpie...@gmail.com wrote:
I am trying to use nested if statements in Cobol. As far as I can tell I am following the style guides, but keep receiving the error:
file_name.cob:64: Error: syntax error, unexpected ELSE
^ This is the second ELSE statement
The purpose of the code is to function as a Caesar cipher, but it seems to only be the nested if statements that are producing the error. I tried putting the nested statements after the ELSE clause of the initial IF statement, but that was
Thank you too sir. I had same issue, looking around for hours how to sort it out!Assuming you pasted the code verbatim in your example, the periods in
I am using open-cobol, and and compiling with the '-free' option on the 1.1 compiler
IF CharCount < 26
ADD firstnum, CharCount GIVING stringShift.
DISPLAY stringShift.
IF FUNCTION MOD(stringShift, 26) IS NOT ZERO
MOVE FUNCTION MOD(stringShift, 26) to stringShift
DISPLAY stringShift
MOVE abc(stringShift:stringShift) TO newChar
DISPLAY newChar
STRING newString DELIMITED BY "", newChar DELIMITED BY SIZE INTO newString
DISPLAY newString
ELSE
STRING newString DELIMITED BY "", searchChar DELIMITED BY SIZE INTO newString
DISPLAY newString
END-IF
ELSE
STRING newString DELIMITED BY "", searchChar DELIMITED BY SIZE INTO newString
DISPLAY newString
END-IF.
Note: I know this is a beginner question, but have looked at a lot of documentation and am at a loss.
Thanks!
the two statements immediately after "IF CharCount < 26" are part of the >> problem... If you are using END-IF scope delimiters, do NOT use periods >> at the end of any statement except the last statement in a paragraph!
The period at the end of "ADD firstnum, CharCount GIVING stringShift."
terminates the IF - not at all what you intended.
HTH
Funny that this post showed up today... just last night I was thinking
that COBOL should have an option to DISallow the use of periods thus
making sure there is no chance of misinterpretation...
This of course would mean getting rid of the diagnostic/error that
occurs if there is no period on the statement BEFORE a paragraph start.
THAT error always annoyed the hello out of me - if there is a NEW
paragraph name why is there an error? The previous paragraph obviously
has therefore ended. Same argument can be applied to having the useless period immediately AFTER the paragraph name!
On Wednesday, November 3, 2021 at 2:36:34 PM UTC, Kerry Liles wrote:unsuccessful as well.
On 11/3/2021 7:46 AM, Tony Ennis wrote:
On Thursday, 25 April 2013 at 20:00:23 UTC+1, Kerry Liles wrote:
On 4/25/2013 2:38 PM, kpie...@gmail.com wrote:
I am trying to use nested if statements in Cobol. As far as I can tell I am following the style guides, but keep receiving the error:
file_name.cob:64: Error: syntax error, unexpected ELSE
^ This is the second ELSE statement
The purpose of the code is to function as a Caesar cipher, but it seems to only be the nested if statements that are producing the error. I tried putting the nested statements after the ELSE clause of the initial IF statement, but that was
Funny that this post showed up today... just last night I was thinkingThank you too sir. I had same issue, looking around for hours how to sort it out!Assuming you pasted the code verbatim in your example, the periods in
I am using open-cobol, and and compiling with the '-free' option on the 1.1 compiler
IF CharCount < 26
ADD firstnum, CharCount GIVING stringShift.
DISPLAY stringShift.
IF FUNCTION MOD(stringShift, 26) IS NOT ZERO
MOVE FUNCTION MOD(stringShift, 26) to stringShift
DISPLAY stringShift
MOVE abc(stringShift:stringShift) TO newChar
DISPLAY newChar
STRING newString DELIMITED BY "", newChar DELIMITED BY SIZE INTO newString
DISPLAY newString
ELSE
STRING newString DELIMITED BY "", searchChar DELIMITED BY SIZE INTO newString
DISPLAY newString
END-IF
ELSE
STRING newString DELIMITED BY "", searchChar DELIMITED BY SIZE INTO newString
DISPLAY newString
END-IF.
Note: I know this is a beginner question, but have looked at a lot of documentation and am at a loss.
Thanks!
the two statements immediately after "IF CharCount < 26" are part of the >>>> problem... If you are using END-IF scope delimiters, do NOT use periods >>>> at the end of any statement except the last statement in a paragraph!
The period at the end of "ADD firstnum, CharCount GIVING stringShift." >>>> terminates the IF - not at all what you intended.
HTH
that COBOL should have an option to DISallow the use of periods thus
making sure there is no chance of misinterpretation...
This of course would mean getting rid of the diagnostic/error that
occurs if there is no period on the statement BEFORE a paragraph start.
THAT error always annoyed the hello out of me - if there is a NEW
paragraph name why is there an error? The previous paragraph obviously
has therefore ended. Same argument can be applied to having the useless
period immediately AFTER the paragraph name!
How would you expect a compiler to distinguish a paragraph name from an misspelt operand, e.g.
DISPLAY data-name
paragraph-name ADD something
?
What I have started doing is putting the full stop before and after the paragraph name as follows
DISPLAY data-name
. paragraph-name. ADD something
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 48:43:17 |
Calls: | 6,648 |
Files: | 12,200 |
Messages: | 5,330,095 |