Skip to main content

Declaratives Use Statement Control

Is there a way to turn the Use Statement in a Declarative on and off with code (IF or WHEN) or users.

I've inherited a lot of older code that sometimes sticks with file-locks, and would like to find the guilty party without "scrambling" production/live code.

I had seen that another version of COBOL had a WHEN statement that allowed for control, but wasn't certain if Visual COBOL had something similar.

Thanks



------------------------------
Eric Boatman
Application Programmer
SMC Packaging
Springfield MO US
------------------------------

Declaratives Use Statement Control

Is there a way to turn the Use Statement in a Declarative on and off with code (IF or WHEN) or users.

I've inherited a lot of older code that sometimes sticks with file-locks, and would like to find the guilty party without "scrambling" production/live code.

I had seen that another version of COBOL had a WHEN statement that allowed for control, but wasn't certain if Visual COBOL had something similar.

Thanks



------------------------------
Eric Boatman
Application Programmer
SMC Packaging
Springfield MO US
------------------------------

There is no option that I know of to automatically turn these on or off at run-time.

You could use constants and conditional compilation to turn these on or off but this is done at compile time not at run-time.

$set constant USE-DECLARE "NO"
 identification division.
 program-id. testdeclare.
 procedure division.
 declaratives.
 $if USE-DECLARE = "YES"
 my-error section.
     use after standard error procedure on input.
     display "File error".
 $end
 end declaratives.

Other than that, you might code your own logic, turning declarative statements on or off depending on the contents of an environment variable.

       identification division.
       program-id. testdeclare.
       working-storage section.
       01 use-declare pic x(10) value spaces.
         88 declare-on  value "yes".
         88 declare-off value "off".
       procedure division.
       declaratives.
       my-error section.
           use after standard error procedure on input.
           if declare-on
              display "File error"
           end-if

       end declaratives.

           display "USE-DECLARE" upon environment-name
           accept use-declare from environment-value

           *>  further statements.

           goback.



------------------------------
Chris Glazier
Principal Technical Support Specialist
Rocket Forum Shared Account
------------------------------

There is no option that I know of to automatically turn these on or off at run-time.

You could use constants and conditional compilation to turn these on or off but this is done at compile time not at run-time.

$set constant USE-DECLARE "NO"
 identification division.
 program-id. testdeclare.
 procedure division.
 declaratives.
 $if USE-DECLARE = "YES"
 my-error section.
     use after standard error procedure on input.
     display "File error".
 $end
 end declaratives.

Other than that, you might code your own logic, turning declarative statements on or off depending on the contents of an environment variable.

       identification division.
       program-id. testdeclare.
       working-storage section.
       01 use-declare pic x(10) value spaces.
         88 declare-on  value "yes".
         88 declare-off value "off".
       procedure division.
       declaratives.
       my-error section.
           use after standard error procedure on input.
           if declare-on
              display "File error"
           end-if

       end declaratives.

           display "USE-DECLARE" upon environment-name
           accept use-declare from environment-value

           *>  further statements.

           goback.



------------------------------
Chris Glazier
Principal Technical Support Specialist
Rocket Forum Shared Account
------------------------------

Thanks for responding ...

At this point I'll just have two versions ... one for production and one to look for file locks.



------------------------------
Eric Boatman
Application Programmer
SMC Packaging
Springfield MO US
------------------------------