View previous topic :: View next topic
|
Author |
Message |
jaffarhussain
New User
Joined: 26 Nov 2010 Posts: 30 Location: Hyderabad
|
|
|
|
Hi Intellects,
F25BM.
IF VA00-CF = '0'
NEXT SENTENCE
ELSE
GO TO F25BM-FN.
F2515.
MOVE '0' TO VX00-CF.
MOVE MW41-VEH-SER-NBR
TO VX00-INTRM-VIN
PERFORM F80-VX00-R THRU F80-FN.
IF IK = '0'
MOVE '1' TO VX00-CF.
How does NEXT SENTENCE flow goes::: Is it will go for PARA F2515 OR
Move to PERFORM F80-VX00-R THRU F80-FN and continue from there. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
There is a link to "IBM Manuals" at the top of the page. There are manuals for the current releases of the Compiler. Read about NEXT SENTENCE and if you find something that is not clear, post what you found and your doubt. Someone will be able to clarify.
This should be very easy to test for yourself. What happens when you run this. Adding a few DISPLAYs would also help you see what happens. . . |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Can someone tell me why (even "experienced") people code like this
Code: |
IF VA00-CF = '0'
NEXT SENTENCE
ELSE
GO TO F25BM-FN.
|
instead of like this
Code: |
IF VA00-CF NOT = '0'
GO TO F25BM-FN.
|
?
If your answer is "to drive you nuts," then I think you are right. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hi Phil,
I've worked several places that really discourage the use of NOT logic. . .
I was never able to get a good reason for this, but i suspect that someone sometime got burned by a NOT a OR b compare. . . |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Well Dick, I totally disagree.
I think people should be more negative. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Well, that's a good start. . .
d |
|
Back to top |
|
|
jaffarhussain
New User
Joined: 26 Nov 2010 Posts: 30 Location: Hyderabad
|
|
|
|
Hi All,
Code generated ia pacbol code.. So It's not the manually written.
Generated by pacbase tools..
So we can find lot of next sentence and Go to in the program. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Thanks for the info Jaffar.
I feel much better knowing that instead of a programmer writing dumb code, they wrote a program that writes dumb code. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
That's nothing, Ph.. Phil. Have you ever seen the output from a Cobol Decision Table pre-processor? And then see the people who use negative conditions for the test, along with Y and N for the route through the table. Is that two negatives make a positive? |
|
Back to top |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
IMO, the worst aspect of this code not the avoidance of negative logic and not even the use of GO TO, it is the use of "NEXT SENTENCE", which introduces a dependency on the period (full stop). |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Well, Don, at least it is all generated code. So, as long as the generator works... it probably hasn't had a new version for a while!
The DT processor I saw generated bus-loads of GO TOs to generated paragraph-names.
You could make the Decision Tables look nice, but the generated code was a mess. I guess it is the "easy" way to generate code. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
Today I found a few programs that have
Code: |
IF a OR b
CONTINUE
ELSE
PERFORM ...
END-IF |
It is a bit less worst than NEXT SENTENCE, but I hate that too!
To make it easy with some fellow programmers, I code:
Code: |
IF NOT (a OR b)
PERFORM ...
END-IF |
instead of:
Code: |
IF NOT a AND NOT b
PERFORM ...
END-IF |
|
|
Back to top |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
Well, to each his own, but in my case I find that decoding:
Code: |
IF a OR b
CONTINUE
ELSE
PERFORM ....
END-IF |
takes a few less brain cycles than:
Code: |
IF NOT (a OR b)
PERFORM ....
END-IF |
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
I agree with Don,
I really dislike negativation (new word?).
and since I don't use periods,
except after the CONTINUE just before the 9999-exit. exit. at the end of every section.
but, i'd almost (read just almost) rather deal with NOT
than deal with mixed case.
I work with idiots who create a CAPS OFF situation by creating a VALUE with a lower case literal (when the lower case is not needed). sometimes I either create a copybook
or when I really feel like pissing them off, I make the literal caps
and then I code a CONVERT to LOWER-CASE in initialization. That really winds them up because I am wasting so many resources. |
|
Back to top |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
I have mixed feelings about mixed case. I like mixed case comments because I find them easier to read, but don't like mixed case code.
In any case, we should all be thankful that Cobol is not case sensitive. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Code: |
IF VA00-CF = '0'
NEXT SENTENCE
ELSE
GO TO F25BM-FN.
|
The above example is an easy one to answer about the NEXT SENTENCE. Since the IF itself is terminated with a period/full-stop, control will continue with the start of the next sentence, which is located immediately after the period/full-stop for the IF.
Code: |
IF VA00-CF = '0'
NEXT SENTENCE
ELSE
GO TO F25BM-FN
END-IF |
This is the ugly one. The IF itself is termnated by the END-IF, but, so what? say IBM. The NEXT SENTENCE causes a hunt for the next full-stop/period, and control will pass to the first part of the sentence after that next full-stop.
I hope that no-one makes use of this particular "feature" of the "IBM Extension" that allows NEXT SENTENCE with END-IF.
On the "TO NOT, OR NOT TO NOT" debate, I admit to no preference. If the business spec says "if it is not green it has to be in the warehouse, otherwise it can be outside" then that is how I would code it. I wouldn't turn it around with a CONTINUE.
I would make it look nice, and write it as clearly as I consider possible.
I'm still thinking about that NEXT SENTENCE. It is an entirely invisible GO TO. Something which sites should happily ban from being used. If you use END-IF, don't use NEXT SENTENCE, even though the compiler will let you. It can just so easily go wrong. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I'm becoming quite impressed (but early days yet) with my little compiler.
Code: |
IDENTIFICATION DIVISION.
PROGRAM-ID. NEXTSNT.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 W-DISPLAY-WHEN-COMPILED PIC X(8)BX(8).
01 W-TEST-ALWAYS-NEGATIVE PIC X VALUE "N".
88 W-TEST-POSITIVE VALUE "Y".
PROCEDURE DIVISION.
MOVE WHEN-COMPILED TO W-DISPLAY-WHEN-COMPILED
DISPLAY W-DISPLAY-WHEN-COMPILED
PERFORM A-PARA-CALLED-A
PERFORM A-PARA-CALLED-B
PERFORM A-PARA-CALLED-C
STOP RUN
.
A-PARA-CALLED-A.
IF NOT W-TEST-POSITIVE
NEXT SENTENCE
ELSE
DISPLAY "A-DISPLAY 00 never to be done"
GO TO A-PARA-CALLED-B
END-IF
DISPLAY "There is an awful lot of crucial code here"
DISPLAY "A-DISPLAY 01 missed in error"
* Just for fun, I wonder if "OPT" would flag any of the code as
* unaccessible? Any kind soul like to let us know?
*
GO TO A-PARA-CALLED-B
.
DISPLAY "A-DISPLAY 02 it jumped to here"
.
A-PARA-CALLED-B.
IF NOT W-TEST-POSITIVE
CONTINUE
ELSE
DISPLAY "B-DISPLAY 00 never to be done"
END-IF
DISPLAY "B-DISPLAY 01 Not missed in error"
.
DISPLAY "B-DISPLAY 02 it didn't jump to here"
.
A-PARA-CALLED-C.
IF NOT W-TEST-POSITIVE
NEXT SENTENCE
ELSE
DISPLAY "C-DISPLAY 00 never to be done"
END-IF
.
DISPLAY "C-DISPLAY 01 Not missed in error"
.
DISPLAY "C-DISPLAY 02 it didn't jump to here"
.
|
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Forgot to include the output from the above.
Code: |
08/30/11 09.01.12
A-DISPLAY 02 it jumped to here
B-DISPLAY 01 Not missed in error
B-DISPLAY 02 it didn't jump to here
C-DISPLAY 01 Not missed in error
C-DISPLAY 02 it didn't jump to here |
The IF-NEXT SENTENCE with no period/full-stop behaves very badly.
The IF-NEXT SENTENCE with a period/full-stop is equivalent to the IF-CONTINUE with no period/full-stop.
Don't mix "NEXT SENTENCE" and "END-IF" .
If you see a program which mixes them, and where there is no period/full-stop for the END-IF, you have a problem. |
|
Back to top |
|
|
|