Highlighted
Honored Contributor.
Honored Contributor.
1758 views

missing End-Try swallows tail of program

Jump to solution

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.

0 Likes
2 Solutions

Accepted Solutions
Highlighted
Outstanding Contributor.
Outstanding Contributor.

RE: missing End-Try swallows tail of program

Jump to solution

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.

View solution in original post

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: missing End-Try swallows tail of program

Jump to solution

Should be just:

     $set NOIMPLICITSCOPE WARNINGS(2)

View solution in original post

0 Likes
5 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: missing End-Try swallows tail of program

Jump to solution

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...

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

RE: missing End-Try swallows tail of program

Jump to solution

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.

View solution in original post

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

RE: missing End-Try swallows tail of program

Jump to solution

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"?

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: missing End-Try swallows tail of program

Jump to solution

Should be just:

     $set NOIMPLICITSCOPE WARNINGS(2)

View solution in original post

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

RE: missing End-Try swallows tail of program

Jump to solution

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

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.