
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
It appears that in the following managed console program, if there is no run-time exception, "swallows" up the tail end of the program if the End-Try is missing. There appear to be no warnings, etc., when the program is compiled.
$set checkdiv"ENTCOBOL".
program-id. Program1 as "cblTestTryCatch1.Program1".
* You can use the CHECKDIV"ENTCOBOL" directive so that you get an division by zero error returned.
* Adding an ON SIZE ERROR would also allow you to handle the error in your code.
* The $set directive shown above accomplishes this.
data division.
working-storage section.
01 Junk Pic X.
01 A Pic 9 value 1.
01 B Pic 9 value 1.
01 C Pic 9 value 2.
procedure division.
Declare Exception1 as type Exception
Try
Compute C = B / A
Display "C = ", C
Catch Exception1
Display Exception1::Message
* End-Try.
Display "End of program..."
Accept Junk
goback.
end program Program1.
Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Remember that conditional statements in Cobol can also be terminated by a full stop which is the old standard. You can use “Display Exception1:Message.” The example has a full stop after goback so all statements are taken as part of the Catch clause.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi Austin1, you have to use the NOIMPLICITSCOPE directive in order to get warnings in this situation. I would tend to agree that this should be the default...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Remember that conditional statements in Cobol can also be terminated by a full stop which is the old standard. You can use “Display Exception1:Message.” The example has a full stop after goback so all statements are taken as part of the Catch clause.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
OK, let me check that out.
Can you give me the exact syntax of the $set directive for this "NOIMPLICITSCOPE"?
Also, apparently (?) may need the exact syntax of the $set directive for the "WARNINGS(3)" or WARNINGS"3"?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
OK, thanks. That worked - it caused a blue squiggly line under the period on the goback statement, and hovering over this, it said "COBCH1227 : Scope terminator END-TRY generated implicitly" and on a Rebuild it did list this as a warning message in the output window.
Time to move on to more important items, I'm sure everyone agrees.
Thanks