Highlighted
Absent Member.
Absent Member.
10189 views

Vision File Access in Visual Cobol

Jump to solution

[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.
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Vision File Access in Visual Cobol

Jump to solution
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.

View solution in original post

0 Likes
21 Replies
Highlighted
Absent Member.
Absent Member.

RE: Vision File Access in Visual Cobol

Jump to solution
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.

0 Likes
Highlighted
Visitor.

RE: Vision File Access in Visual Cobol

Jump to solution
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!
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Vision File Access in Visual Cobol

Jump to solution
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.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Vision File Access in Visual Cobol

Jump to solution
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?
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Vision File Access in Visual Cobol

Jump to solution
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.

View solution in original post

0 Likes
Highlighted
Absent Member.
Absent Member.

RE: Vision File Access in Visual Cobol

Jump to solution
How do we convert our AcuCobol .acu compiled code to a .dll?
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Vision File Access in Visual Cobol

Jump to solution
There is no conversion utility available to take .acu code and turn it into .dlls.

You will need to create a Visual Studio 2010 native COBOL Link Library project and import your source code programs into it.

You would then need to build the project and the resultant output file generated is a .dll.
How much manual conversion of source code from Acu to Visual COBOL that will be necessary depends entirely on what Acu features you are using in these programs.

0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: Vision File Access in Visual Cobol

Jump to solution
Using the suggestions here, we were able to successfully access Vision Files from a managed project, by calling a native Cobol program which actually does the file access. This works okay, but we've been unable to access files using remote name notation (files stored on our server and accessible via AcuServer). Is access to AcuServer files via remote name notation not supported in Visual Cobol? (since it's just an extension of the Acu File Handling, I thought it would be?).
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Vision File Access in Visual Cobol

Jump to solution
Hi Tony,

No, currently AcuServer is not part of the Visual COBOL suite and is not included in the ACUFH libraries which is the Vision File handler that is part of Visual COBOL.

We're not sure if AcuServer or File Share would be the best way to access remote Vision files going forward. Please send your thoughts on this to Dominique Sacre and Mark Warren.

Thanks,

Steve
0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: Vision File Access in Visual Cobol

Jump to solution
Thanks, Steve - by "File Share", are you referring to a Windows file share of a folder over a network? If so, that won't work for us as we use AcuServer over the Internet.

(removed second question as it was user error......... works fine in VC)
0 Likes
Highlighted
Super Contributor.
Super Contributor.

RE: Vision File Access in Visual Cobol

Jump to solution
Having successfully been able to use Vision files from the WinBook project (by creating ReadBook, a copy of LegacyBook which uses ACUFH and is a native Cobol project, with the necessary changes to BookWrapper), I tried to use the WebBook tutorial. The page creates fine, but when I try to access the data file, I get an error "173 Called program file not found in drive/directory [ReadBook]". The ReadBook.dll is in the BIN folder of the WebForm project, same folder as BookWrapper, and BookWrapper is called okay.

Is the web page able to use a native Cobol program (ie native Cobol READBOOK called from managed program BookWrapper)?

Does this error message indicate that "ReadBook" can't be found, or that the error occurred within ReadBook.dll?
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.