View previous topic :: View next topic
|
Author |
Message |
sbalajibe
New User
Joined: 15 Aug 2005 Posts: 62
|
|
|
|
Hi All,
can u please help me out ... i am getting error in the following evaluate statement on NEXT SENTENCE ..
EVALUATE TRUE
WHEN SQLCODE = 00
NEXT SENTENCE
WHEN OTHER
<do error routine?>
END-EVALAUTE.
thanks in advance
Balaji |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
It would be helpfull if you can give us the exact error message. Thanks. :-)
O. |
|
Back to top |
|
|
sbalajibe
New User
Joined: 15 Aug 2005 Posts: 62
|
|
|
|
Hi Ofer71 ,
i am getting error like
?The "NEXT SENTENCE" phrase was invalid in this context
thanks
Balaji |
|
Back to top |
|
|
ofer71
Global Moderator
Joined: 27 Dec 2005 Posts: 2358 Location: Israel
|
|
|
|
As far as I know (and I'm not a COBOL expert) - The NEXT SENTENCE clause is part of the SEARCH and IF statements only.
O. |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Code "CONTINUE" in place of "NEXT SENTENCE"... that will solve your problem...
Regards,
Priyesh. |
|
Back to top |
|
|
lordholnapult Currently Banned New User
Joined: 01 Feb 2006 Posts: 5 Location: Italy
|
|
|
|
I think NEXT SENTENCE was a cobol '86 code version of the CONTINUE code command, created in COBOL 2.
or am I Wrong ?
|
|
Back to top |
|
|
cevelavl
New User
Joined: 20 Feb 2006 Posts: 4
|
|
|
|
1) Clause NEXT SENTENCE is valid only in IF and SEARCH statements.
2) Non-conditional statement CONTINUE from ANSI Cobol 85 is possible everywhere.
3) So it can be in EVALUATE statement and in other conditional statements inclusive IF and SEARCH too. |
|
Back to top |
|
|
DARAPRADEEP
New User
Joined: 13 Apr 2005 Posts: 7
|
|
|
|
hi,
you can code like this
EVALUATE TRUE
WHEN SQLCODE not = 00
<do error routine?>
WHEN OTHER
CONTINUE
END-EVALUATE.
I think if the condetions are one or two use IF is better.
thanks,
pradeep. |
|
Back to top |
|
|
umeshkmrsh
New User
Joined: 21 Sep 2005 Posts: 79 Location: India
|
|
|
|
Hi frnds,
Let me add this point to your discussion.
CONTINUE is a replacement of NEXT SENTENCE in COBOL-II. As older one NEXT SENTENCE doesn?t understands key worlds like END-IF, END-SEARCH, END-STRING, etc which are used to terminate a sentence. In Cobol-I only way to terminate a sentence was '.' .
Now coming to why EVALUATE doesn?t supports NEXT SENTENCE? Reason is -- the EVALUATE statement was introduced with COBOL-II.
Using NEXT SENTENCE in place of CONTINUE can be dangerous if you are using COBOL-II.
I have not tried explaining everything...but I hope it will help you guys.
Correction's always welcome. |
|
Back to top |
|
|
small_world
New User
Joined: 22 Jul 2005 Posts: 24 Location: pune
|
|
|
|
COBOL II introduced the CONTINUE verb, which means "do nothing."
But wait a minute -- isn't that what NEXT SENTENCE means?
No, not quite. NEXT SENTENCE is actually an unconditional branch to whatever follows the next period. In effect, it is a restricted form of GO TO.
Consider the following fragment:
[ warning: bad code ahead ]
IF NOT INPUT-EOF
IF INPUT-REC-TYPE = '55'
PERFORM 2100-PROCESS-WTN
ELSE
NEXT SENTENCE
END-IF
ADD +1 TO INPUT-COUNT.
Quick, now: when INPUT-REC-TYPE is '00', what happens to INPUT-COUNT? Answer: nothing. NEXT SENTENCE branches around the ADD statement.
If you're used to thinking of NEXT SENTENCE as "do nothing," this result may come as a surprise. Before COBOL II, we not only didn't have CONTINUE, we also didn't have END-IF, or any of its kindred. The kind of situation shown above didn't arise.
With COBOL II and its successors, however, these situations can arise. Our old reflexes are no longer reliable.
Conclusions
Do not code NEXT SENTENCE. Ever.
If you really mean "do nothing," code CONTINUE.
If you really mean "branch to the next sentence," code a GO TO, or otherwise rearrange the code. If you insist on a GO TO, code it explicitly -- don't disguise it.
|
|
Back to top |
|
|
|