Skip to Main Content

Oracle Forms

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Reading data from Comm Port - Scanner

StratosAug 27 2013 — edited Aug 28 2013

Hi everyone! I need your help.

I am using Oracle Forms 6i and i want to use an rs-232 Handheld Scanner, which i have already connected on the COM3 port of the pc. I want to use this type of scanner because i want to prevent user from typing a barcode in text item. The only input method must be the SCANNER.

I have made a lot of search for the implementation (most topics refer to weight scale) but the problem is how to finally get the input from the scanner when a barcode is scanned . How i catch the event that something scanned ?

I have done the following:

1. Create an OLE container ('block3.ole_control4') and connect it with file mscomm32.ocx deom system32 (Right click on the item and selecting Miscrosoft Communication Control does nothing; doesn't show any icon on the item)

2. Import OLE library MSCOMMLib_IMSComm

3. Create a text item <<data2>> on a block to show the scanned barcode and  a button with the following code in the 'WHEN-BUTTON-PRESSED'

Declare

CommHandle ole2.obj_type; -- to hold the interface pointer

hold number;

NUM1 number;

string1 Varchar2(2000);

string2 OleVar;

errCode         pls_integer;

errSrc          varchar2(200);

errDescription  varchar2(2000);

errHelpfile     varchar2(200);

errHelpContext  pls_integer;

Begin

  CommHandle := forms_ole.get_interface_pointer('block3.ole_control4');

  Message(CommHandle);pause;

  OLE2.SET_PROPERTY(CommHandle, 'CommPort', 3);

  /* try to close COM2, in case it was open for some reason.

  0 = FALSE, -1 = TRUE

  */

  begin

  OLE2.SET_PROPERTY(CommHandle, 'PortOpen', 0);--port open

  exception

  when others then

  Message('Port is open');Message(' ');

  end;

  -- Set device to 9600 baud, no parity, 8 data, and 1 stop bit.

  OLE2.SET_PROPERTY(CommHandle, 'Settings', '9600,N,8,1');

 

  -- Open the port. 0 = FALSE, -1 = TRUE

  OLE2.SET_PROPERTY(CommHandle, 'PortOpen', -1);

  Begin

     --***************here is the problem******************

     :data2 := OLE2.GET_CHAR_PROPERTY(CommHandle, 'Input');

     message(:data2);pause;

     --Get_Ole_Var(CommHandle, 26); --this code raises error

     --string1:=var_to_Char(string2); --this code raises error

  Exception

         when form_ole_failure then

       errCode := last_ole_exception( errSrc,

                                      errDescription,

                                      errHelpfile,

                                      errHelpContext);

       message('ERR:'||errSrc||': '||errDescription);pause;

     When Others Then

     message('Error In Reading');pause;

     Message('1'||SQlcode||sqlerrm);pause;

    

     End;

/*

OLE2.set_PROPERTY(CommHandle,'InBufferSize',1200);

OLE2.SET_PROPERTY(CommHandle, 'InBufferCount', '0');

*/

/*

Exception

When Others Then

Message(SQlcode||sqlerrm);pause;

*/

End;

The main problem is how i finally get the INPUT.

Is the 'WHEN-BUTTON-PRESSED' is the correct trigger to put the code << OLE2.GET_CHAR_PROPERTY(CommHandle, 'Input');  >>  ?

In here it causes  error 305500-non Oracle Exception.

Please i look forward for your help.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 25 2013
Added on Aug 27 2013
2 comments
713 views