Vision files in C#

Hello All,

I was wondering if there was a way to read indexed vision files directly in a C# program, without the use of the XDBC program?

 

Thanks


Dave

  • There is. The ACUCOBOL-GT runtime can be called by a C# program (we provide an interface called wrunet.dll). This would allow to have COBOL do the I-O and returns results to C#.

    We also have a Vision File System Interface (written in C). You have to contact your Sales Rep as a Non-disclosure is involved when using the FSI.

  • Verified Answer

    Thanks, I've gotten a copy of the Vision File System Interface, and I can get the testvis.c program to compile in Visual Studio 2015, though I do get several warnings when I do so. The ones that concern me are the following:
    Warning C4013 'SetLArgv0' undefined; assuming extern returning int
    Warning C4013 'ACSetValueShort' undefined; assuming extern returning int
    Warning C4013 'ACSetValueLong' undefined; assuming extern returning int

    I follow the instructions and copy the testvis.vlc license file into the executable directory, but when I run the compiled program it fails on the call to v5_init(), returning a 0 code. Have you used this tool in the past, and if so, is there anything I should be looking at here to rectify the problem? It looks to me like something might be missing from the project, or not setup properly.

    Thanks

    Dave
  • Verified Answer

    The warnings are due to missing prototypes for those functions. You can add these lines after the #include files to avoid them:

    extern void SetLArgv0(const char *);
    extern void ACSetValueShort(const char *, int, short);
    extern void ACSetValueLong(const char *, int, long);

    As for the v5i_init() failure you should contact technical support to make sure you have the correct license for your installation. There isn't much else that would cause v5i_init() to fail so a license mismatch is the most likely explanation.
  • Thanks for the help, I found that I was using a 9.24 version of acme.lib and avision5.lib, and this version of acme.lib seems to have been missing the some of the necessary methods. I grabbed an old 6.10 version of these files and was able to run the C program and have it create the vision file. Now that I've got that working, I want to take the C code and create a C# program that does the same thing using the dlls instead of the libraries. I've got a quick shell thrown together, however the call to v5_init() is always returning 0. Here's the code:

    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    namespace VisionInterface
    {
    class Program
    {
    [DllImport("C:\\Users\\t850681\\Documents\\Visual Studio 2015\\Projects\\VisionInterface\\VisionInterface\\obj\\x86\\Debug\\acme.dll", CallingConvention = CallingConvention.Cdecl)]
    public static extern void SetLArgv0([MarshalAs(UnmanagedType.LPStr)] string progName);
    [DllImport("C:\\Users\\t850681\\Documents\\Visual Studio 2015\\Projects\\VisionInterface\\VisionInterface\\obj\\x86\\Debug\\avision5.dll", CallingConvention = CallingConvention.Cdecl)]
    public static extern int v5_init();
    static void Main(string[] args)
    {
    string exeName = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName char.MinValue;
    SetLArgv0(exeName);
    if(v5_init() == 0)
    MessageBox.Show("v5_init failed");
    }
    }
    }
    Has anyone tried this with C# and had any success? Can you point me in the right direction?

    Thanks


    Dave
  • Thanks for the help, I found that I was using a 9.24 version of acme.lib and avision5.lib, and this version of acme.lib seems to have been missing the some of the necessary methods. I grabbed an old 6.10 version of these files and was able to run the C program and have it create the vision file. Now that I've got that working, I want to take the C code and create a C# program that does the same thing using the dlls instead of the libraries. I've got a quick shell thrown together, however the call to v5_init() is always returning 0. Here's the code:

    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    namespace VisionInterface
    {
    class Program
    {
    [DllImport("C:\\Users\\t850681\\Documents\\Visual Studio 2015\\Projects\\VisionInterface\\VisionInterface\\obj\\x86\\Debug\\acme.dll", CallingConvention = CallingConvention.Cdecl)]
    public static extern void SetLArgv0([MarshalAs(UnmanagedType.LPStr)] string progName);
    [DllImport("C:\\Users\\t850681\\Documents\\Visual Studio 2015\\Projects\\VisionInterface\\VisionInterface\\obj\\x86\\Debug\\avision5.dll", CallingConvention = CallingConvention.Cdecl)]
    public static extern int v5_init();
    static void Main(string[] args)
    {
    string exeName = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName char.MinValue;
    SetLArgv0(exeName);
    if(v5_init() == 0)
    MessageBox.Show("v5_init failed");
    }
    }
    }
    Has anyone tried this with C# and had any success? Can you point me in the right direction?

    Thanks


    Dave
  • Thanks for the help, I found that I was using a 9.24 version of acme.lib and avision5.lib, and this version of acme.lib seems to have been missing the some of the necessary methods. I grabbed an old 6.10 version of these files and was able to run the C program and have it create the vision file. Now that I've got that working, I want to take the C code and create a C# program that does the same thing using the dlls instead of the libraries. I've got a quick shell thrown together, however the call to v5_init() is always returning 0. Here's the code:

    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    namespace VisionInterface
    {
    class Program
    {
    [DllImport("C:\\Users\\t850681\\Documents\\Visual Studio 2015\\Projects\\VisionInterface\\VisionInterface\\obj\\x86\\Debug\\acme.dll", CallingConvention = CallingConvention.Cdecl)]
    public static extern void SetLArgv0([MarshalAs(UnmanagedType.LPStr)] string progName);
    [DllImport("C:\\Users\\t850681\\Documents\\Visual Studio 2015\\Projects\\VisionInterface\\VisionInterface\\obj\\x86\\Debug\\avision5.dll", CallingConvention = CallingConvention.Cdecl)]
    public static extern int v5_init();
    static void Main(string[] args)
    {
    string exeName = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName char.MinValue;
    SetLArgv0(exeName);
    if(v5_init() == 0)
    MessageBox.Show("v5_init failed");
    }
    }
    }
    Has anyone tried this with C# and had any success? Can you point me in the right direction?

    Thanks


    Dave
  • After much head scratching, I've managed to get the v5_init to work, directory issues, and issues regarding the name of the .vlc file. Now I'm stuck on the v5_open call to open the file. It's supposed to return an IFilePtr in C, which looks to me like is should just be an IntPtr in C#, so long as I don't care about the underlying structure. However, this call keeps returning 0, and does not open the file output. Code follows:
    using System;
    using System.IO;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    namespace VisionInterface
    {
    class Program
    {
    #region acme.dll
    [DllImport("acme.dll", CallingConvention = CallingConvention.Cdecl)]
    public static extern void SetLArgv0([MarshalAs(UnmanagedType.LPStr)] string progName);
    [DllImport("acme.dll", CallingConvention = CallingConvention.Cdecl)]
    public static extern void ACSetValueLong([MarshalAs(UnmanagedType.LPStr)]
    string variableName,
    int constInt,
    long value);
    [DllImport("acme.dll", CallingConvention = CallingConvention.Cdecl)]
    public static extern void ACSetValueShort([MarshalAs(UnmanagedType.LPStr)]
    string variableName,
    int constInt,
    short value);
    #endregion
    #region avision5.dll
    [DllImport("avision5.dll", CallingConvention = CallingConvention.Cdecl)]
    public static extern int v5_init();
    [DllImport("avision5.dll", CallingConvention = CallingConvention.Cdecl)]
    public static extern IntPtr v5_open([MarshalAs(UnmanagedType.LPStr)]string fileName, int mode, [MarshalAs(UnmanagedType.LPStr)]string lParams);

    #endregion
    #region Constants
    public const int Finput = 0;
    public const int Foutput = 1;
    public const int Fio = 2;
    public const int Fextend = 3;

    #endregion
    static void Main(string[] args)
    {

    Directory.SetCurrentDirectory("C:\\Users\\t850681\\Documents\\Visual Studio 2015\\Projects\\VisionInterface\\VisionInterface\\obj\\x86\\Debug\\");
    string exeName = System.Reflection.Assembly.GetEntryAssembly().Location;
    SetLArgv0(exeName);
    if(v5_init() == 0)
    MessageBox.Show("v5_init failed");
    ACSetValueLong("V_BUFFERS", 0, 512L);
    ACSetValueShort("V_VERSION", 0, 5);
    string fileName = Directory.GetCurrentDirectory() "\\test.vis";
    IntPtr fileHandle = v5_open(fileName, 1, "10,10,1");
    }
    }
    }
  • So turns out the issue was that the file didn't exist. Opening a file output through this method does not create the file, as it does normally when opening output. I had to add a call to v5_make first, and then it worked. like a charm.
  • So turns out the issue was that the file didn't exist. Opening a file output through this method does not create the file, as it does normally when opening output. I had to add a call to v5_make first, and then it worked. like a charm.