Vision File Access in Visual Cobol

[Migrated content. Thread originally posted on 25 March 2011]

We are very new at the .net world but have purchased Visual Cobol because it can access our current vision file data without converting the data (so we understand).

Our first issue is that we can't seem to find a way to get a project to see our current vision data files. Can someone please send me some pointers/clues/hints on how you get a new project to see a vision data file.

Thanks for ANY help.
  • kthomp24 originally wrote:
    We are very new at the .net world but have purchased Visual Cobol because it can access our current vision file data without converting the data (so we understand).

    Our first issue is that we can't seem to find a way to get a project to see our current vision data files. Can someone please send me some pointers/clues/hints on how you get a new project to see a vision data file.


    I guess it sort of depends on what you mean by "see".

    If you right click the project name in the solution explorer, the context menu should have an option (about 1/3 of the way down) labeled "Add". Select that then select "Existing Item". You should then see a file picker dialog. On the bottom right corner of that dialog there's a combo box which allows you to specify the mask for files to display. Drop down the combo box so it displays "All Files" and navigate to the folder where your vision data files are and you should be able to select them.

    On the other hand if you mean something different by "see" then you need to expand your question a bit.

  • kthomp24 originally wrote:
    We are very new at the .net world but have purchased Visual Cobol because it can access our current vision file data without converting the data (so we understand).

    Our first issue is that we can't seem to find a way to get a project to see our current vision data files. Can someone please send me some pointers/clues/hints on how you get a new project to see a vision data file.


    I guess it sort of depends on what you mean by "see".

    If you right click the project name in the solution explorer, the context menu should have an option (about 1/3 of the way down) labeled "Add". Select that then select "Existing Item". You should then see a file picker dialog. On the bottom right corner of that dialog there's a combo box which allows you to specify the mask for files to display. Drop down the combo box so it displays "All Files" and navigate to the folder where your vision data files are and you should be able to select them.

    On the other hand if you mean something different by "see" then you need to expand your question a bit.

  • I'll assume by "seeing" these files, you mean you want your programs to use Vision files instead of MF ISAM files. To do this, you need to enable the Vision (Acu) file handler by adding a compiler directive.

    Before you do this, you should also know that you can only use ACUFH in a Native (not Managed) project. This selection is done when you create the project. I don't know if you can convert an existing Managed-code project to Native, or vice-versa (anyone else want to answer this?).

    The directive for using the ACUFH file handler is:

    CALLFH("ACUFH")
    This can be set in Visual Studio in your Project's Properties page (in the COBOL category, under "Additional Directives".

    You can also set it for individual programs, by adding it directly in your COBOL source program using a $SET statement. At the top of the program (ahead of the Identification Division) put:

          $SET CALLFH("ACUFH")
           Identification Division.
          *  comment

    (be sure the $SET starts in column 1 or 7, depending on the type of source format you use. In other words, the same column you put the asterisk for comments).

    Also, you may need to set config variables that affect the Vision file handling - what you would have done in ACUCOBOL using a runtime config file (cblconfig). Things like V_VERSION, V_BUFFERS, etc. (I'm not sure what the full list of supported variables is). The ACUFH file handler will look for /etc/cblconfig by default. You can specify your own config file by setting the A_CONFIG environment variable. To do this in your Visual COBOL project, follow these steps:

    1. In the Solution Explorer, under your project look for a file named Application.config. If it isn't there, add it: right-click the project, select Add -> New Item. In the window that pops up, select Application Configuration File, then click the Add button.
    2. Double-click the Application.config file. In the small window that pops up, click on the Environment tab. In the Name field, type A_CONFIG and in the Value field type the name of your config file (I called mine "acufh.cfg").

    If you don't include a full path to the config file, it will assume the current directory - by default the directory where the VC puts the compiled executable (e.g. workspace\project\bin\x86\debug). That's also where it will look for (and create) data files. If you want to keep them in a different directory, you can set your project's working directory explicitly. Open the Project's Properties, click on the Debug category, then under Start Options you can set your working directory. You can put a fully-qualified path, but this could prevent your project from being portable (if you want to move it, or share a copy with someone). The path, however, appears to be relative to the Project directory, so if you want the working directory to be the Workspace directory just put ".." in the Working Directory field (to indicate the parent directory of the project, which is the workspace). At least it seemed to work for me - Your Mileage May Vary!
  • You will also have to add a reference to link in the ACUFH.LIB import library.

    The location for this file is C:\Program Files (x86)\Micro Focus\Vision 2.0\lib or lib64 depending on if you are compiling for 32-bit or 64-bit.

    You can add this to the LIB environment variable or you can reference it under Properties->COBOL->Link Settings->Link to these Libraries.
  • In Native mode you lose the ability to use windows forms and .net GUI screen building....is that correct? So if we wanted to use that type of screen building we are not able to attach/view/access Vision file formatted data?
  • In Native mode you lose the ability to use windows forms and .net GUI screen building....is that correct? So if we wanted to use that type of screen building we are not able to attach/view/access Vision file formatted data?
  • Verified Answer

    It is true that currently the Acu Vision File support is only available in native COBOL applications but these applications, if compiled as .dlls can be called from a managed code application such as a Winform application using a .NET technology known as Platform Invoke.

    Visual COBOL does most of the required work under the covers so you can call these native applications as if they were any typical COBOL subprogram using a linkage section and procedure division using header to pass parameters.

    So if you had a native .DLL named TESTSUB.DLL which looked like:

    id division.
    program-id. TESTSUB.
    working-storage section.
    01 pass-param pic x(20).
    procedure division using pass-param.

    *> access Vision files and pass back data.
    goback.

    this could be accessed in the managed code application using the standard:

    call "TESTSUB" using pass-param

    TESTSUB.dll should be placed in the same location as the main .EXE of the application so that it can be found.

    Also, look at the ILPINVOKE compiler directive for more information.

    There is also a small sample program that demonstrates this functionality.
    Please see C:\Users\Public\Documents\Micro Focus\Visual COBOL 2010\Samples\pinvoke

    Thanks.
  • How do we convert our AcuCobol .acu compiled code to a .dll?
  • How do we convert our AcuCobol .acu compiled code to a .dll?
  • How do we convert our AcuCobol .acu compiled code to a .dll?