Highlighted
Honored Contributor.
Honored Contributor.
2199 views

Need COBSW type settings in Visual Studio for animating and testing

Jump to solution

Hello,

We have the following for setting runtime switches in the BAT file that brings up our production runtime environment:

SET COBSW=+B-F-N

We want to understand how to do this in Visual COBOL 2.2 Update 2 (Visual Studio 2013) for when we are animating and testing, both native and managed.

For a typical managed program, Under Project Properties, on the COBOL tab, in the Build Settings area we currently have the following:

anim cobidy"L:\URISYS\COMPPROG" sourceformat"Variable" warnings"2" max-

error"100" ilgen"sub" noint iltarget"x86" constant"DEBUG(1)"

and for a typical native program, Under Project Properties, on the COBOL tab, in the Build Settings area we currently have the following:

anim cobidy"C:\URISYS\COMPPROG" warnings"2" max-error"100"

Do we somehow add these run-time switches to this?  Exactly how?

Thanks!

0 Likes
2 Solutions

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Need COBSW type settings in Visual Studio for animating and testing

Jump to solution

Hello,

For managed projects, you may add an application configuration file and set the runtime switch. Here are the steps:

  1. right-click on the project
  2. select Add > New Item
  3. select Application Configuration File
  4. click Add (and App.config is added to the project)
  5. right-click on App.config
  6. click Edit
  7. enter COBSW in the Name field
  8. enter +B-F-N in the Value field
  9. click Set
  10. click OK

For native projects, you may follow the same steps as above. The only difference is that the configuration file is called Application.config

Regards,

–Ғɑɳօ

View solution in original post

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Need COBSW type settings in Visual Studio for animating and testing

Jump to solution

I just ran a test and these COBSW settings work for me in both native code or managed code either by setting them in the app.config file as COBSW with +B-F-N or by passing them on the command line on the debug tab using (+B-F-N)

Try the following program and tell me if it works for you? The result should be that when run the RTS error 163 caused by invalid data in the move (CHECKNUM is on) should be suppressed and the text file myfile.txt should not contain the embedded nulls before each non displayable character.

      $set checknum 
       program-id. Program1.
       input-output section.
           select test-file assign to "myfile.txt"
                           organization is line sequential
                           file status is file-status.
       data division.
       file section.
       fd test-file.
       01 test-record pic x(10).
       working-storage section.
       01 file-status pic x(2) value spaces.
       01 myspaces pic x(10) value spaces.
       01 field-1  redefines myspaces pic s9(5)v9(2).
       01 field-2 pic s9(5)v9(2).
       procedure division.

           move field-1 to field-2
           open output test-file
           display file-status
           move x"010203" to test-record
           write test-record
           close test-file
           
           goback.
           
       end program Program1.

View solution in original post

0 Likes
6 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Need COBSW type settings in Visual Studio for animating and testing

Jump to solution

Hello,

For managed projects, you may add an application configuration file and set the runtime switch. Here are the steps:

  1. right-click on the project
  2. select Add > New Item
  3. select Application Configuration File
  4. click Add (and App.config is added to the project)
  5. right-click on App.config
  6. click Edit
  7. enter COBSW in the Name field
  8. enter +B-F-N in the Value field
  9. click Set
  10. click OK

For native projects, you may follow the same steps as above. The only difference is that the configuration file is called Application.config

Regards,

–Ғɑɳօ

View solution in original post

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

RE: Need COBSW type settings in Visual Studio for animating and testing

Jump to solution

I tried this for a managed program, and IT DID NOT WORK.  In other words, there was no difference, even though there should have been (I can run this with the runtime production BAT file and same data, and I get different result, due to the runtime switches as mentioned earlier).  Here is the resulting App.config contents:

<?xml version="1.0" encoding="utf-8"?>

<configuration>

 <configSections>

   <!--The following code declares a section group for application configuration -->

   <sectionGroup name="MicroFocus.COBOL.Application">

     <section name="Switches" type="System.Configuration.NameValueSectionHandler" />

     <section name="Environment" type="System.Configuration.NameValueSectionHandler" />

   </sectionGroup>

   <!--The following code declares a section group for run-time configuration -->

   <sectionGroup name="MicroFocus.COBOL.Runtime">

     <section name="Tunables" type="System.Configuration.NameValueSectionHandler" />

     <section name="Switches" type="System.Configuration.NameValueSectionHandler" />

   </sectionGroup>

 </configSections>

 <MicroFocus.COBOL.Application>

   <Switches />

   <Environment>

     <add key="COBSW" value="+B-F-N" />

   </Environment>

 </MicroFocus.COBOL.Application>

</configuration>

Also, please note what I said in my initial request, related to the version of VC and VS, etc.

Thanks

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Need COBSW type settings in Visual Studio for animating and testing

Jump to solution

My reading of the documentation indicates that runtime switches are not supported in managed code.  Under Run-time Switches topic, there is this restriction:

       Restriction: These switches are supported for native COBOL only.

This was in the 2.3 documentation and I think in all earlier versions as well.

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

RE: Need COBSW type settings in Visual Studio for animating and testing

Jump to solution

That may be true, but from your wording, it sounds like you are just giving a preliminary "opinion" and not necessarily a final answer (?).

Surely there is some type of solution, as I would think that the COBSW runtime switches are pretty basic - they have been around for a long time.  Please also note that I have now also tried this for native (doing the Application.config approach) and it did not work either.  Is there anything else we can try or do?

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Need COBSW type settings in Visual Studio for animating and testing

Jump to solution

I just ran a test and these COBSW settings work for me in both native code or managed code either by setting them in the app.config file as COBSW with +B-F-N or by passing them on the command line on the debug tab using (+B-F-N)

Try the following program and tell me if it works for you? The result should be that when run the RTS error 163 caused by invalid data in the move (CHECKNUM is on) should be suppressed and the text file myfile.txt should not contain the embedded nulls before each non displayable character.

      $set checknum 
       program-id. Program1.
       input-output section.
           select test-file assign to "myfile.txt"
                           organization is line sequential
                           file status is file-status.
       data division.
       file section.
       fd test-file.
       01 test-record pic x(10).
       working-storage section.
       01 file-status pic x(2) value spaces.
       01 myspaces pic x(10) value spaces.
       01 field-1  redefines myspaces pic s9(5)v9(2).
       01 field-2 pic s9(5)v9(2).
       procedure division.

           move field-1 to field-2
           open output test-file
           display file-status
           move x"010203" to test-record
           write test-record
           close test-file
           
           goback.
           
       end program Program1.

View solution in original post

0 Likes
Highlighted
Honored Contributor.
Honored Contributor.

RE: Need COBSW type settings in Visual Studio for animating and testing

Jump to solution

My sincere apologies to all.  Yes, both methods work, exactly as they were presented earlier.  The approach using App.config / Application.config works and the approach using (+B-F-N) in the Command Line Arguments of the Debug tab works.  I have tested both approaches with both native and managed, and they all work.  In managed, I have tested with console projects and win forms projects, and they all work.

So what was I doing wrong earlier?  Very simple (now that I see it).  In our environment, in practically all cases, we have the program that we are working on, which is a DLL, whether it is a managed or native.  So, we typically have a solution that has the DLL program in question as one project along with another project which has a simple program that starts first and calls or invokes the DLL program, passing whatever needs to be passed (user ID, etc.)  Essentially, this simple caller / invoker program simulates the main menu etc. of the production application.  Well, regardless of the approach used, the run-time COBSW switch settings need to be established in the start-up CALLER / INVOKER program, not in the called/invoked DLL program.  When I finally realized this and tried the approaches at the right place, everything worked as advertised.  Thanks and sorry about my earlier confusion.

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.