[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