Solved

MSCOMM in Oracle forms 6i

Posted on 2003-12-11
7
3,163 Views
Last Modified: 2007-12-19
Can anybody give some pointers on how to use MSCOMM in Oracle forms 6i?
0
Comment
Question by:luvjd
  • 3
7 Comments
 
LVL 5

Expert Comment

by:FBIAGENT
Comment Utility
I'm sorry about my ignorance, but what is MSCOMM?
0
 

Expert Comment

by:goip
Comment Utility
I also will ask this Question can u plz tell me that what is MSCOMM. thanx.
0
 
LVL 2

Expert Comment

by:bcarlis
Comment Utility
The MSComm control provides serial communications for your application by allowing the transmission and reception of data through a serial port.

The MSComm control provides the following two ways for handling communications:

Event-driven communications is a very powerful method for handling serial port interactions. In many situations you want to be notified the moment an event takes place, such as when a character arrives or a change occurs in the Carrier Detect (CD) or Request To Send (RTS) lines. In such cases, use the MSComm control's OnComm event to trap and handle these communications events. The OnComm event also detects and handles communications errors. For a list of all possible events and communications errors, see the CommEvent property.


You can also poll for events and errors by checking the value of the CommEvent property after each critical function of your program. This may be preferable if your application is small and self-contained. For example, if you are writing a simple phone dialer, it may not make sense to generate an event after receiving every character, because the only characters you plan to receive are the OK response from the modem.
Each MSComm control you use corresponds to one serial port. If you need to access more than one serial port in your application, you must use more than one MSComm control. The port address and interrupt address can be changed from the Windows Control Panel.

Bill :>)

0
 
LVL 2

Accepted Solution

by:
bcarlis earned 125 total points
Comment Utility
luvjd,

I found this on Oracle OTN:
http://forums.oracle.com/forums/thread.jsp?forum=82&thread=232458&message=715543&q=6d6f64656d#715543

Hope it answers your question....

Thanks Bill


We have an old Forms application that needed to dial a modem through the serial port. Here's some code to maybe get you started. I'm going to assume you're on Windows.

Step 1:

Attach an OLE object to your canvas, and point that to MSCOMMLib.MSComm.1 (the MS serial port handler).

Step 2:
Sample code. This is our DIAL_PHONE proedure that receives a phone number, opens the COM port (in our case COM2), sends the modem dial strings, and waits for a respomse back from the mode. I'm not an expert, we just taught ourselves enough to get this one functionality to work.

***************************************

/* Receives phone string, including area code, and dials a modem on COM2. Disconnects 9 seconds
after dialing (S7=09), assuming the telemarketer will have switched control to their headsets by then
*/

PROCEDURE dial_phone(phone_number IN OUT VARCHAR2) IS

CommHandle ole2.obj_type; -- to hold the interface pointer
hold number;
modem_init VARCHAR2(30) := 'ATQ0V1E1S0=0X4S7=5';
dial_string VARCHAR2(20);
com_err VARCHAR2(100);
outBuf NUMBER;
inchar varchar2(100) := ' ';
loop_count NUMBER(9) := 0;
dial_msg varchar2(100);
time_start binary_integer;
time_end binary_integer;
z NUMBER := 0;
delay NUMBER := 100000;

--Return from check exchange
phone_to_dial VARCHAR2(15);

X VARCHAR2(15);

BEGIN

IF phone_number IS NULL
THEN x := win_alert('OK','No phone number to dial.');
raise form_trigger_failure;
END IF;

logit(:global.debug,'======== Begin DIAL_PHONE (' || phone_number || ') ==============');


-- Check exchange #, If it's in local calling area don't use an area code. Will also
-- add user's long distance data to the number returned, if necessary,
phone_to_dial := check_exchange(phone_number);


CommHandle := forms_ole.get_interface_pointer('b_main_prospect_info.mscomm_ocx');

--Set up the dial string with the passed phone number
dial_string := 'ATDT9' || phone_to_dial;

dial_msg := 'Dialing ' || dial_string || '...';
message(dial_msg,NO_ACKNOWLEDGE);
synchronize;

-- Set the com port to COM2.
OLE2.SET_PROPERTY(CommHandle, 'CommPort', 2);

-- try to close COM2, in case it was open for some reason. 0 = FALSE, -1 = TRUE
begin
OLE2.SET_PROPERTY(CommHandle, 'PortOpen', 0);
exception
when others then null; -- if already open, ignore error
end;

-- Set modem to 1200 baud, no parity, 8 data, and 1 stop bit.
OLE2.SET_PROPERTY(CommHandle, 'Settings', '1200,N,8,1');

-- Open the port. 0 = FALSE, -1 = TRUE
OLE2.SET_PROPERTY(CommHandle, 'PortOpen', -1);

-- find out if the com port has opened successfully. 0 = FALSE, -1 = TRUE
hold := OLE2.GET_num_PROPERTY(CommHandle, 'PortOpen');

IF hold = 0 THEN --the com port could not be opened.
X := WIN_ALERT('OK', 'Your COM2 port (modem) could not be opened. Contact your supervisor');
RAISE form_trigger_failure;
END IF;

-- Send the attention command to the modem. Default setup string
OLE2.SET_PROPERTY(CommHandle, 'Output', modem_init || chr(13));
z := 0;
loop
z := z + 1;
exit when z = delay;
end loop;

-- Run program that give windows control to process info. in output buffer to modem
HOST(:global.gtec_dir || 'DEVENTS.EXE');

--Send the dial string
OLE2.SET_PROPERTY(CommHandle, 'Output', dial_string || chr(13));
z := 0;
loop
z := z + 1;
exit when z = delay;
end loop;

-- Run program that give windows control to process info. in output buffer to modem
HOST(:global.gtec_dir || 'DEVENTS.EXE');

--Clear the dialing string from the input buffer
OLE2.SET_PROPERTY(CommHandle, 'InBufferCount', '0');

/**************************************************
* Loop until we get a BUSY or NO CARRIER signal.
************************************************** */
loop_count := 0;
time_start := dbms_utility.get_time; -- store loop start in 1/100's of seconds
inchar := ' ';

LOOP
-- Run program that give windows control to process info. in output buffer to modem
HOST(:global.gtec_dir || 'DEVENTS.EXE');
outBuf := OLE2.GET_NUM_PROPERTY(CommHandle, 'InBufferCount');

--Read the response data in the serial port, character by character. Build INCHAR
inchar := inchar || OLE2.GET_CHAR_PROPERTY(CommHandle, 'Input');
--message(inchar);
OLE2.SET_PROPERTY(CommHandle, 'InBufferCount', 0);

/***************************************************
* Check to see if a BUSY has been returned
*************************************************** */
IF INSTR(inchar, 'BUSY') <> 0 THEN
--Close the port
OLE2.SET_PROPERTY(CommHandle, 'PortOpen', 0);

-- Release the MSCOMM handle
OLE2.release_obj(CommHandle);

--Set the list to busy
:b_main_prospect_info.CALL_STATUS_LIST := 'BUSY_NO_ANSWER';

--Process a call marked as Busy/No Answer
process_busy_no_answer;
EXIT;
END IF;

IF INSTR(inchar, 'RING') <> 0 THEN
message(inchar || ' ...', ACKNOWLEDGE);
inchar := ' ';
END IF;

/***************************************************
* Check to see if a NO CARRIER has been returned
*************************************************** */

IF INSTR(inchar, 'NO CARRIER') <> 0 THEN -- happens when they switch to headset. No message shows.
--message('NO DIAL TONE' || ' ...', ACKNOWLEDGE);
inchar := ' ';
GO_ITEM('CALL_STATUS_LIST');
EXIT;
END IF;

/***************************************************
*Check to see if a OK has been returned
*************************************************** */
IF INSTR(inchar, 'OK') <> 0 THEN
message(inchar || ' ...', ACKNOWLEDGE);
inchar := ' ';
GO_ITEM('CALL_STATUS_LIST');
EXIT;
END IF;

loop_count := loop_count + 1;
IF MOD(loop_count,1000) = 0
THEN dial_msg := dial_msg || '.';
message(dial_msg,NO_ACKNOWLEDGE);
synchronize;
END IF;
time_end := dbms_utility.get_time;
-- Compare current time to loop start time in 1/100's of seconds. If more than 10 seconds, end.
if time_end - time_start > 1500
THEN message('Problem dialing number. Result response not received from modem.', ACKNOWLEDGE);
message(' ');
GO_ITEM('CALL_STATUS_LIST');
EXIT;
END IF;


END LOOP;

OLE2.SET_PROPERTY(CommHandle, 'Output', 'ATH' || chr(13));
z := 0;
loop
z := z + 1;
exit when z = delay/10;
end loop;

--Close the port

OLE2.SET_PROPERTY(CommHandle, 'PortOpen', 0);
OLE2.release_obj(CommHandle);

--Give list box focus
update tele.gtec_login_tbl
set last_dialed = phone_number,
last_dialed_time = sysdate
where v_user_id = user;
forms_ddl('commit');

if to_number(:global.address_id) > 0
then GO_ITEM('b_main_prospect_info.call_status_list');
else GO_ITEM('b_manual_call.v_call_outcome');
end if;
EXCEPTION
when others then
logit(:global.debug,'Error dialing phone');
--Give list box focus
if to_number(:global.address_id) > 0
then GO_ITEM('b_main_prospect_info.call_status_list');
else GO_ITEM('b_manual_call.v_call_outcome');
end if;
END;
0
 
LVL 2

Expert Comment

by:bcarlis
Comment Utility

What else do you need to close the Question???

Bill.....
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now