Skip to main content

[Migrated content. Thread originally posted on 14 November 2011]

Hello,

I am trying to write a VC program using OPOS.

Firstly I created a Visual C# program to test the library:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using OposPOSPrinter_1_9_Lib;

namespace TestOposC
{
    public partial class Form1 : Form
    {
        OPOSPOSPrinter printer = new OPOSPOSPrinter();
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            printer.Open("PRINTER");
            printer.ClaimDevice(1000);
            printer.DeviceEnabled = true;
            printer.CutPaper(100);
            printer.Close();
        }
    }
}

It works with no problems.

But trying to do the same in Visual COBOL is like a pain. I cannot figure out how to create the var for referencing the library:

      $set ilusing"Interop.OposPosPrinter_1_9_lib"
       class-id TestOPos.Form1 is partial
                 inherits type System.Windows.Forms.Form.
       
       working-storage section.
      *************************************************************************************
       01  myPrinter      type OPOSPOSPrinter. *> COBCH0845: Unknown class 'OPOSPOSPrinter'
      *************************************************************************************
       
       method-id NEW.
       procedure division.
           invoke self::InitializeComponent
           goback.
       end method.

       method-id button1_Click final private.
       procedure division using by value sender as object e as type System.EventArgs.
           invoke myPrinter::Open("PRINTER").
           invoke myPrinter::ClaimDevice(1000).
           set myPrinter::DeviceEnabled to 1.
           invoke myPrinter::CutPaper(100).
           invoke myPrinter::Close().
       end method.
     
       end class.



Here you can find the two projects, if needed: Projects

Regards

[Migrated content. Thread originally posted on 14 November 2011]

Hello,

I am trying to write a VC program using OPOS.

Firstly I created a Visual C# program to test the library:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using OposPOSPrinter_1_9_Lib;

namespace TestOposC
{
    public partial class Form1 : Form
    {
        OPOSPOSPrinter printer = new OPOSPOSPrinter();
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            printer.Open("PRINTER");
            printer.ClaimDevice(1000);
            printer.DeviceEnabled = true;
            printer.CutPaper(100);
            printer.Close();
        }
    }
}

It works with no problems.

But trying to do the same in Visual COBOL is like a pain. I cannot figure out how to create the var for referencing the library:

      $set ilusing"Interop.OposPosPrinter_1_9_lib"
       class-id TestOPos.Form1 is partial
                 inherits type System.Windows.Forms.Form.
       
       working-storage section.
      *************************************************************************************
       01  myPrinter      type OPOSPOSPrinter. *> COBCH0845: Unknown class 'OPOSPOSPrinter'
      *************************************************************************************
       
       method-id NEW.
       procedure division.
           invoke self::InitializeComponent
           goback.
       end method.

       method-id button1_Click final private.
       procedure division using by value sender as object e as type System.EventArgs.
           invoke myPrinter::Open("PRINTER").
           invoke myPrinter::ClaimDevice(1000).
           set myPrinter::DeviceEnabled to 1.
           invoke myPrinter::CutPaper(100).
           invoke myPrinter::Close().
       end method.
     
       end class.



Here you can find the two projects, if needed: Projects

Regards
Your project seems to be using the COM version of this control.
I cannot test this with your projects as the actual OPOSPOSPrinter .dlls are not included in the project.

I did find actual .NET assembly versions for this file at:

OPOSPOSPrinter assemblies

When I install the version 1.13 and add a reference to it I can use the following in your project:


$set ilusing"POS.Devices"
       class-id TestOPos.Form1 is partial
                 inherits type System.Windows.Forms.Form.
       
       working-storage section.
       01  myPrinter      type OPOSPOSPrinter.
       
       method-id NEW.
       procedure division.
           invoke self::InitializeComponent
           goback.
       end method.

       method-id button1_Click final private.
       procedure division using by value sender as object e as type System.EventArgs.
           set myPrinter to new type OPOSPOSPrinter
           invoke myPrinter::Open("PRINTER").
           invoke myPrinter::ClaimDevice(1000).
           set myPrinter::DeviceEnabled to true
           invoke myPrinter::CutPaper(100).
           invoke myPrinter::Close().
       end method.
     
       end class.

[Migrated content. Thread originally posted on 14 November 2011]

Hello,

I am trying to write a VC program using OPOS.

Firstly I created a Visual C# program to test the library:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using OposPOSPrinter_1_9_Lib;

namespace TestOposC
{
    public partial class Form1 : Form
    {
        OPOSPOSPrinter printer = new OPOSPOSPrinter();
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            printer.Open("PRINTER");
            printer.ClaimDevice(1000);
            printer.DeviceEnabled = true;
            printer.CutPaper(100);
            printer.Close();
        }
    }
}

It works with no problems.

But trying to do the same in Visual COBOL is like a pain. I cannot figure out how to create the var for referencing the library:

      $set ilusing"Interop.OposPosPrinter_1_9_lib"
       class-id TestOPos.Form1 is partial
                 inherits type System.Windows.Forms.Form.
       
       working-storage section.
      *************************************************************************************
       01  myPrinter      type OPOSPOSPrinter. *> COBCH0845: Unknown class 'OPOSPOSPrinter'
      *************************************************************************************
       
       method-id NEW.
       procedure division.
           invoke self::InitializeComponent
           goback.
       end method.

       method-id button1_Click final private.
       procedure division using by value sender as object e as type System.EventArgs.
           invoke myPrinter::Open("PRINTER").
           invoke myPrinter::ClaimDevice(1000).
           set myPrinter::DeviceEnabled to 1.
           invoke myPrinter::CutPaper(100).
           invoke myPrinter::Close().
       end method.
     
       end class.



Here you can find the two projects, if needed: Projects

Regards
Thanks for your help. It works. :-)