Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

A CONS is an object which cares. -- Bernie Greenberg.


devel / comp.lang.cobol / Re: Nested If else statements

SubjectAuthor
* Re: Nested If else statementsTony Ennis
`* Re: Nested If else statementsKerry Liles
 `* Re: Nested If else statementsRobert Jones
  `- Re: Nested If else statementsKerry Liles

1
Re: Nested If else statements

<cbd02258-bff4-482f-8aa0-711d0d558b77n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=222&group=comp.lang.cobol#222

  copy link   Newsgroups: comp.lang.cobol
X-Received: by 2002:a05:600c:b43:: with SMTP id k3mr14686499wmr.159.1635939985948;
Wed, 03 Nov 2021 04:46:25 -0700 (PDT)
X-Received: by 2002:a05:6902:124a:: with SMTP id t10mr26363675ybu.493.1635939985427;
Wed, 03 Nov 2021 04:46:25 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.128.87.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.cobol
Date: Wed, 3 Nov 2021 04:46:25 -0700 (PDT)
In-Reply-To: <klbuai$4jf$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a02:8084:d003:a280:a1a8:f197:daf1:1b5c;
posting-account=B_KJwAoAAAA4ZnBGOWRXK_ynhr831SVt
NNTP-Posting-Host: 2a02:8084:d003:a280:a1a8:f197:daf1:1b5c
References: <edf05ad4-440c-4405-b7b1-0f0e7ce1417f@googlegroups.com> <klbuai$4jf$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cbd02258-bff4-482f-8aa0-711d0d558b77n@googlegroups.com>
Subject: Re: Nested If else statements
From: tonygennis@gmail.com (Tony Ennis)
Injection-Date: Wed, 03 Nov 2021 11:46:25 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Tony Ennis - Wed, 3 Nov 2021 11:46 UTC

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 unsuccessful as well.
> >
> > 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
Thank you too sir. I had same issue, looking around for hours how to sort it out!

Re: Nested If else statements

<slu6pg$o45$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=223&group=comp.lang.cobol#223

  copy link   Newsgroups: comp.lang.cobol
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: kerry.liles@gmail.com (Kerry Liles)
Newsgroups: comp.lang.cobol
Subject: Re: Nested If else statements
Date: Wed, 3 Nov 2021 10:36:31 -0400
Organization: A noiseless patient Spider
Lines: 63
Message-ID: <slu6pg$o45$1@dont-email.me>
References: <edf05ad4-440c-4405-b7b1-0f0e7ce1417f@googlegroups.com>
<klbuai$4jf$1@dont-email.me>
<cbd02258-bff4-482f-8aa0-711d0d558b77n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 3 Nov 2021 14:36:32 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="dcc10d5ccf1e61814bb6b08b968f93f2";
logging-data="24709"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18i8y81KrGgCVMejWGRbv1E"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.0
Cancel-Lock: sha1:8Njd6wgI1uSUb2d+0xPibWoCNMg=
In-Reply-To: <cbd02258-bff4-482f-8aa0-711d0d558b77n@googlegroups.com>
Content-Language: en-US
 by: Kerry Liles - Wed, 3 Nov 2021 14:36 UTC

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 unsuccessful as well.
>>>
>>> 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
> Thank you too sir. I had same issue, looking around for hours how to sort it out!
>

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!

Re: Nested If else statements

<e38d3a12-d343-470f-a87a-c54299d83854n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=224&group=comp.lang.cobol#224

  copy link   Newsgroups: comp.lang.cobol
X-Received: by 2002:ac8:7fc3:: with SMTP id b3mr6500304qtk.247.1635965012165;
Wed, 03 Nov 2021 11:43:32 -0700 (PDT)
X-Received: by 2002:a25:389:: with SMTP id 131mr26365375ybd.501.1635965011925;
Wed, 03 Nov 2021 11:43:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.cobol
Date: Wed, 3 Nov 2021 11:43:31 -0700 (PDT)
In-Reply-To: <slu6pg$o45$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=35.177.228.69; posting-account=YfOAvQoAAAB-xX6lFkGnJ-ulWzvPONPD
NNTP-Posting-Host: 35.177.228.69
References: <edf05ad4-440c-4405-b7b1-0f0e7ce1417f@googlegroups.com>
<klbuai$4jf$1@dont-email.me> <cbd02258-bff4-482f-8aa0-711d0d558b77n@googlegroups.com>
<slu6pg$o45$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <e38d3a12-d343-470f-a87a-c54299d83854n@googlegroups.com>
Subject: Re: Nested If else statements
From: 0robert.jones@gmail.com (Robert Jones)
Injection-Date: Wed, 03 Nov 2021 18:43:32 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 88
 by: Robert Jones - Wed, 3 Nov 2021 18:43 UTC

On Wednesday, November 3, 2021 at 2:36:34 PM UTC, Kerry Liles wrote:
> 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 unsuccessful as well.
> >>>
> >>> 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
> > Thank you too sir. I had same issue, looking around for hours how to sort it out!
> >
> 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!

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

Re: Nested If else statements

<slun9i$qi6$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=225&group=comp.lang.cobol#225

  copy link   Newsgroups: comp.lang.cobol
Path: i2pn2.org!i2pn.org!paganini.bofh.team!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: kerry.liles@gmail.com (Kerry Liles)
Newsgroups: comp.lang.cobol
Subject: Re: Nested If else statements
Date: Wed, 3 Nov 2021 15:18:10 -0400
Organization: A noiseless patient Spider
Lines: 77
Message-ID: <slun9i$qi6$1@dont-email.me>
References: <edf05ad4-440c-4405-b7b1-0f0e7ce1417f@googlegroups.com>
<klbuai$4jf$1@dont-email.me>
<cbd02258-bff4-482f-8aa0-711d0d558b77n@googlegroups.com>
<slu6pg$o45$1@dont-email.me>
<e38d3a12-d343-470f-a87a-c54299d83854n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 3 Nov 2021 19:18:10 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="dcc10d5ccf1e61814bb6b08b968f93f2";
logging-data="27206"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19JhmvKAirW1bOJHRu0g4K7"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.0
Cancel-Lock: sha1:D+LZBIbhCIZvBxt3Ov1pqCZ0QfE=
In-Reply-To: <e38d3a12-d343-470f-a87a-c54299d83854n@googlegroups.com>
Content-Language: en-US
 by: Kerry Liles - Wed, 3 Nov 2021 19:18 UTC

On 11/3/2021 2:43 PM, Robert Jones wrote:
> On Wednesday, November 3, 2021 at 2:36:34 PM UTC, Kerry Liles wrote:
>> 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 unsuccessful as well.
>>>>>
>>>>> 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
>>> Thank you too sir. I had same issue, looking around for hours how to sort it out!
>>>
>> 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!
>
> 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
>

ah, good point. I was thinking (only) about the sort of COBOL I have
used the most over the last 50+ years - where Paragraph names have to
start in the A margin (column 8). I often forget about the "looser"
COBOL variants like those available on PCs etc.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor