• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Question How do I pass the required parameters for this .NET class object?

Cecil

17+ years progress programming and still learning.
#1
I still new to this .NET stuff but how do I pass the required parameters for this .NET class object? How do I pass System.Object and system.IntPtr.

1512430702045.png


This is what I've got so far. I think it's asking for the handle of current procedure (THIS-PROCEDURE or THIS-OBJECT) and the handle of an Internal Procedure ( or Method).

Code:
DEFINE VARIABLE ProgressDelegate AS CLASS MMM.Readers.FullPage.ProgressDelegate.

ProgressDelegate = NEW MMM.Readers.FullPage.ProgressDelegate ( ??? ,  ???  ).

Is this the correct?

Code:
DEFINE VARIABLE oAblParent AS System.IntPtr NO-UNDO.

oAblParent = NEW System.IntPtr( INTEGER(THIS-PROCEDURE:HANDLE) ).
 
Last edited:

Cecil

17+ years progress programming and still learning.
#2
How do I convert this C# code into ABL code? I getting stuck again on .NET events not firing.

Code:
using System;
using System.IO.Ports;

class PortDataReceived
{
    public static void Main()
    {
        SerialPort mySerialPort = new SerialPort("COM1");

        mySerialPort.BaudRate = 9600;
        mySerialPort.Parity = Parity.None;
        mySerialPort.StopBits = StopBits.One;
        mySerialPort.DataBits = 8;
        mySerialPort.Handshake = Handshake.None;
        mySerialPort.RtsEnable = true;

        mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);

        mySerialPort.Open();

        Console.WriteLine("Press any key to continue...");
        Console.WriteLine();
        Console.ReadKey();
        mySerialPort.Close();
    }

    private static void DataReceivedHandler(
                        object sender,
                        SerialDataReceivedEventArgs e)
    {
        SerialPort sp = (SerialPort)sender;
        string indata = sp.ReadExisting();
        Console.WriteLine("Data Received:");
        Console.Write(indata);
    }
}
THIS IS WHAT I GOT SO FAR:

Code:
USING System.*.
USING System.IO.Ports.*.

DEFINE VARIABLE SerialPort AS CLASS SerialPort NO-UNDO.

PROCEDURE DataReceived:

    DEFINE INPUT PARAMETER sender AS CLASS Object NO-UNDO.
    DEFINE INPUT PARAMETER e          AS CLASS SerialDataReceivedEventArgs NO-UNDO.

    MESSAGE       SerialPort:ReadBufferSize .
   
    DEFINE VARIABLE chComPortData AS CHARACTER   NO-UNDO.
   
    chComPortData = SerialPort:ReadExisting().
   
    MESSAGE chComPortData.
   
    chComPortData = "".

END PROCEDURE.

SerialPort = NEW SerialPort("COM5").

SerialPort:BaudRate = 115200.
SerialPort:Parity = Parity:NONE.
SerialPort:StopBits = StopBits:One.
SerialPort:DataBits = 8.
SerialPort:Handshake = Handshake:NONE.
SerialPort:RtsEnable = TRUE.

/* SerialPort:DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler); */
SerialPort:DataReceived:Subscribe("DataReceived").

SerialPort:Open().

MESSAGE "IsOpen:" SerialPort:IsOpen.

DO WHILE SerialPort:IsOpen  :


    PROCESS EVENTS.

END.

SerialPort:Close().
 
Last edited:

Cecil

17+ years progress programming and still learning.
#3
Figured it out. I needed to remove the following statement mySerialPort.RtsEnable = true;

However, I get a new error message. I read about this but I thought there was a way around this issue.

1512943949051.png