PABX System with COM WAIT EVENT
Posted: Sat Sep 23, 2006 9:09 am
Hi All !
I used COMMUNICATION port :
- SetComstateDb
- InitCom
- ReadCom
- CloseCom
Anyone can help me how to use COM WAIT EVENT ?
#include "FiveWin.ch"
function Main()
local oDlg, nComm := InitComm()
DEFINE DIALOG oDlg TITLE "Testing Comm functions"
oDlg:bCommNotify = { | nComm, nStatus | BytesAtPort( nComm, nStatus ) }
>>>???? this block for wait event every time for read comport ????<<<
is that true ?
ACTIVATE DIALOG oDlg ;
ON INIT EnableCommNotification( nComm, oDlg:hWnd, 20, 20 )
CloseComm( nComm )
return nil
function InitCOMM()
local cDcb, nError, nBytes
local nComm := OpenComm( "COM1", 1024, 128 )
if ! BuildCommDcb( "COM1:9600,n,8,1", @cDcb )
MsgStop( "Error BUILD!" )
return .f.
endif
#ifdef __CLIPPER__
if ! SetCommState( cDcb )
#else
if ! SetCommState( nComm, cDcb )
#endif
MsgStop( "Error SETCOMM!" )
return .f.
endif
return nComm
function BytesAtPort( nComm, nStatus )
local cBuffer := Space(20 )
Msginfo( nSTATUS)
ReadComm( nComm, @cBuffer ) // <<<<---- program will lock here
Msginfo( AllTrim( cBuffer ))
return nil
thanks
Areang
I used COMMUNICATION port :
- SetComstateDb
- InitCom
- ReadCom
- CloseCom
Anyone can help me how to use COM WAIT EVENT ?
#include "FiveWin.ch"
function Main()
local oDlg, nComm := InitComm()
DEFINE DIALOG oDlg TITLE "Testing Comm functions"
oDlg:bCommNotify = { | nComm, nStatus | BytesAtPort( nComm, nStatus ) }
>>>???? this block for wait event every time for read comport ????<<<
is that true ?
ACTIVATE DIALOG oDlg ;
ON INIT EnableCommNotification( nComm, oDlg:hWnd, 20, 20 )
CloseComm( nComm )
return nil
function InitCOMM()
local cDcb, nError, nBytes
local nComm := OpenComm( "COM1", 1024, 128 )
if ! BuildCommDcb( "COM1:9600,n,8,1", @cDcb )
MsgStop( "Error BUILD!" )
return .f.
endif
#ifdef __CLIPPER__
if ! SetCommState( cDcb )
#else
if ! SetCommState( nComm, cDcb )
#endif
MsgStop( "Error SETCOMM!" )
return .f.
endif
return nComm
function BytesAtPort( nComm, nStatus )
local cBuffer := Space(20 )
Msginfo( nSTATUS)
ReadComm( nComm, @cBuffer ) // <<<<---- program will lock here
Msginfo( AllTrim( cBuffer ))
return nil
thanks
Areang