Code Comments
Programming Forum and web based access to our favorite programming groups.Learn something new every day, it seems... and so I post it here to show everyone how little I actually know. (note - all compiler references are to IBM mainframe software) I was taught the syntax of IF (condition) [THEN] (imperative statement). . and the compiler enforced this fairly well; even the venerable IKFCBL00 would throw a condition code of 12 on IF FLD1 = ZEROES. ... and this holds for the IBM Enterprise COBOL for z/OS and OS/390 3.2.0 which I presently use at work; it returns IGYPS2079-S Expected a verb or "NEXT SENTENCE", but found ". ". This syntax holds true for those who employ scope-delimiters, as well, as IF FLD1 = ZEROES END-IF ... with or without a period (full stop) following the END-IF generates IGYPS2079-S Expected a verb or "NEXT SENTENCE", but found "END-IF". ... as, some might argue, Well It Should Be. However... I was given a chunk of code to modify, the scenario being that they no longer wanted records with zeroes in a couple of fields. At first I was told that if the second field was zeroes the sign-indicator (a separate alpha field preceding the numeric field... no SIGN LEADING SEPARATE CHARACTER here!) should be blanked out since the indicator was initialised to '+' in another section. The output records were stored in a WORKING STORAGE table and the code started out as: PERFORM 9798-WRITE-DETREC THRU 9798-EX VARYING SUB03 FROM 1 BY 1 UNTIL SUB03 > 14. ... 9798-WRITE-DETREC. * WRITE OUT-REC FROM WK-REC (SUB03). ADD 1 TO OUT-COUNT. * 9798-EX. EXIT. So... I coded the following: 9798-WRITE-DETREC. * IF (WK-FLD1 (SUB03) = ZEROES) IF (WK-FLD2 (SUB03) = ZEROES) GO TO 9798-EX END-IF MOVE SPACES TO WK-FLD2-SIGN (SUB03) END-IF. * WRITE OUT-REC FROM WK-REC (SUB03). ADD 1 TO OUT-COUNT. * 9798-EX. EXIT. ... and ran the job and submitted the test-results for examination. I then received the classic 'I know that's what we told you but it's not what we want...'; seems that they wanted the second '+' back again because it made it easier to eyeball the unformatted data... but I've been burned by 'Take it out... put it back... now take it out again' before so I changed a single character to make it: 9798-WRITE-DETREC. * IF (WK-FLD1 (SUB03) = ZEROES) IF (WK-FLD2 (SUB03) = ZEROES) GO TO 9798-EX END-IF * MOVE SPACES TO WK-FLD2-SIGN (SUB03) END-IF. * WRITE OUT-REC FROM WK-REC (SUB03). ADD 1 TO OUT-COUNT. * 9798-EX. EXIT. Now... as I read the above the the GO TO is predicated upon a second-level conditional... but there is *nothing* predicated on the first. And yet... it compiles and runs and does just what I want. DD
Post Follow-up to this messageYour nested IF ... END-IF *is* an imperative statement (scope terminated conditional statement) and as such THAT is the "action" taken by your outer most IF. This is just the same as: IF A = "A" Add 1 to X On size error Display "here" End-Add End-If or (using another scope terminated conditional) IF A = "A" Evaluate X When "Y" Display "HERE" End-Evaluate End-IF -- Bill Klein wmklein <at> ix.netcom.com <docdwarf@panix.com> wrote in message news:c27n36$h00$1@panix5.panix.com... > > Learn something new every day, it seems... and so I post it here to show > everyone how little I actually know. > > (note - all compiler references are to IBM mainframe software) > > I was taught the syntax of IF (condition) [THEN] (imperative statement )... > and the compiler enforced this fairly well; even the venerable IKFCBL00 > would throw a condition code of 12 on > > IF FLD1 = ZEROES. > > ... and this holds for the IBM Enterprise COBOL for z/OS and OS/390 3.2.0 > which I presently use at work; it returns > > IGYPS2079-S Expected a verb or "NEXT SENTENCE", but found ". ". > > This syntax holds true for those who employ scope-delimiters, as well, as > > IF FLD1 = ZEROES > END-IF > > ... with or without a period (full stop) following the END-IF generates > > IGYPS2079-S Expected a verb or "NEXT SENTENCE", but found "END-IF". > > ... as, some might argue, Well It Should Be. > > However... I was given a chunk of code to modify, the scenario being that > they no longer wanted records with zeroes in a couple of fields. At first > I was told that if the second field was zeroes the sign-indicator (a > separate alpha field preceding the numeric field... no SIGN LEADING > SEPARATE CHARACTER here!) should be blanked out since the indicator was > initialised to '+' in another section. The output records were stored in > a WORKING STORAGE table and the code started out as: > > PERFORM 9798-WRITE-DETREC THRU 9798-EX > VARYING SUB03 FROM 1 BY 1 > UNTIL SUB03 > 14. > ... > > 9798-WRITE-DETREC. > * > WRITE OUT-REC FROM WK-REC (SUB03). > ADD 1 TO OUT-COUNT. > * > 9798-EX. > EXIT. > > So... I coded the following: > > 9798-WRITE-DETREC. > * > IF (WK-FLD1 (SUB03) = ZEROES) > IF (WK-FLD2 (SUB03) = ZEROES) > GO TO 9798-EX > END-IF > MOVE SPACES TO WK-FLD2-SIGN (SUB03) > END-IF. > * > WRITE OUT-REC FROM WK-REC (SUB03). > ADD 1 TO OUT-COUNT. > * > 9798-EX. > EXIT. > > ... and ran the job and submitted the test-results for examination. I > then received the classic 'I know that's what we told you but it's not > what we want...'; seems that they wanted the second '+' back again because > it made it easier to eyeball the unformatted data... but I've been burned > by 'Take it out... put it back... now take it out again' before so I > changed a single character to make it: > > 9798-WRITE-DETREC. > * > IF (WK-FLD1 (SUB03) = ZEROES) > IF (WK-FLD2 (SUB03) = ZEROES) > GO TO 9798-EX > END-IF > * MOVE SPACES TO WK-FLD2-SIGN (SUB03) > END-IF. > * > WRITE OUT-REC FROM WK-REC (SUB03). > ADD 1 TO OUT-COUNT. > * > 9798-EX. > EXIT. > > Now... as I read the above the the GO TO is predicated upon a second-level > conditional... but there is *nothing* predicated on the first. > > And yet... it compiles and runs and does just what I want. > > DD
Post Follow-up to this messageIn article <dAK1c.19044$yZ1.7876@newsread2.news.pas.earthlink.net>, William M. Klein <wmklein@nospam.netcom.com> wrote: >Your nested IF ... END-IF *is* an imperative statement (scope terminated >conditional statement) and as such THAT is the "action" taken by your oute rmost >IF. I know that an inner IF is predicated by the outer, Mr Klein... what I find unusual is that the inner IF has no associated imperative. It is as though I wrote: IF COND-1 IF COND-2 END-IF DISPLAY 'COND-1' END-IF > This is just the same as: > > IF A = "A" > Add 1 to X > On size error > Display "here" > End-Add > End-If Not as I read it... my code is analagous to If A = 'A' Add 1 to X On size error End-Add End-If > >or (using another scope terminated conditional) > > IF A = "A" > Evaluate X > When "Y" > Display "HERE" > End-Evaluate >End-IF Likewise, no... in my code the 'MOVE SPACES' is commented out (sorry for not having made that more clear) so in this case it would be: If A = 'A' Evaluate X When 'Y' End-Evaluate End-If DD ><docdwarf@panix.com> wrote in message news:c27n36$h00$1@panix5.panix.com... > >
Post Follow-up to this messageOn 4-Mar-2004, docdwarf@panix.com wrote: > IF (WK-FLD1 (SUB03) = ZEROES) > IF (WK-FLD2 (SUB03) = ZEROES) > GO TO 9798-EX > END-IF > * MOVE SPACES TO WK-FLD2-SIGN (SUB03) > END-IF. > * > WRITE OUT-REC FROM WK-REC (SUB03). > ADD 1 TO OUT-COUNT. > * > 9798-EX. > EXIT. > > Now... as I read the above the the GO TO is predicated upon a second-level > conditional... but there is *nothing* predicated on the first. > > And yet... it compiles and runs and does just what I want. I really don't understand your post. The internal IF statement is predicat ed by the external IF statement. Am I missing something from your question? What I'm getting is very basic - which is not the type of question I would expect from you.
Post Follow-up to this messageIn IF (WK-FLD1 (SUB03) = ZEROES) IF (WK-FLD2 (SUB03) = ZEROES) GO TO 9798-EX END-IF > * MOVE SPACES TO WK-FLD2-SIGN (SUB03) END-IF. Why don't you think your GO TO 9798-EX is a "perfectly" valid is an "associated imperative" for the innermost IF? What am I missing? -- Bill Klein wmklein <at> ix.netcom.com <docdwarf@panix.com> wrote in message news:c27tc7$2dk$1@panix5.panix.com... > In article <dAK1c.19044$yZ1.7876@newsread2.news.pas.earthlink.net>, > William M. Klein <wmklein@nospam.netcom.com> wrote: outermost > > I know that an inner IF is predicated by the outer, Mr Klein... what I > find unusual is that the inner IF has no associated imperative. It is as > though I wrote: > > IF COND-1 > IF COND-2 > END-IF > DISPLAY 'COND-1' > END-IF > > > Not as I read it... my code is analagous to > > If A = 'A' > Add 1 to X > On size error > End-Add > End-If > > > Likewise, no... in my code the 'MOVE SPACES' is commented out (sorry for > not having made that more clear) so in this case it would be: > > If A = 'A' > Evaluate X > When 'Y' > End-Evaluate > End-If > > DD > > >
Post Follow-up to this messageOn 4-Mar-2004, docdwarf@panix.com wrote: > I know that an inner IF is predicated by the outer, Mr Klein... what I > find unusual is that the inner IF has no associated imperative. It is as > though I wrote: > > IF COND-1 > IF COND-2 > END-IF > DISPLAY 'COND-1' > END-IF How so? I see the inner IF has GO TO 9798-EX as its associated imperative.
Post Follow-up to this messageIn article <c27tse$8ig$1@peabody.colorado.edu>, Howard Brazee <howard@brazee.net> wrote: > >On 4-Mar-2004, docdwarf@panix.com wrote: > > >How so? I see the inner IF has GO TO 9798-EX as its associated imperative.[/color ] My error and apologies to all... this is correct, I misremembered my own posting. DD
Post Follow-up to this messageIn article <F_K1c.19074$yZ1.18995@newsread2.news.pas.earthlink.net>, William M. Klein <wmklein@nospam.netcom.com> wrote: >In > > IF (WK-FLD1 (SUB03) = ZEROES) > IF (WK-FLD2 (SUB03) = ZEROES) > GO TO 9798-EX > END-IF > END-IF. > > >Why don't you think your > > GO TO 9798-EX > >is a "perfectly" valid is an "associated imperative" for the innermost IF? >What am I missing? As noted in my posting to Mr Brazee... my error and apologies, I misremembered my own posting. DD
Post Follow-up to this messageIn article <c27tod$86m$1@peabody.colorado.edu>, Howard Brazee <howard@brazee.net> wrote: > >On 4-Mar-2004, docdwarf@panix.com wrote: > > >I really don't understand your post. The internal IF statement is predica ted >by the external IF statement. This is what Mr Klein pointed out... and in my confusion over these newfangled scope delimiters - barely twenty years old, they are! - I did not notice that what caught my eye was the equivalent of IF COND-1 IF COND-2 (imperative). > >Am I missing something from your question? What I'm getting is very basic - >which is not the type of question I would expect from you. Quite obviously *I* was missing something... but this is a reason to have others look over one's work. Thanks much! DD
Post Follow-up to this messageOn 4-Mar-2004, docdwarf@panix.com wrote: > Quite obviously *I* was missing something... but this is a reason to have > others look over one's work. It's amazing what I've overlooked missing what should have been no-brainers.
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.