Usage
  

Here's how I do this stuff...


STATIC nHandle

...Mainline...

IF OpenOk()
DOProcessing()

ELSE
MsgStop( 'Cannot open port!' )
QUIT

ENDIF


Function OpenOk()

// Open the port

IF ( nHandle := Init_Port( 'COM1', 9600, 8, 0, 0, 8000 ) ) > 0
OutBufClr( nHandle )   // Saw this somewhere...probably ok if unnecessary
Return IsWorking( nHandle )

ENDIF

Return FALSE


Function DOProcessing()

// Get a chunk from the COM port

nChr := InBuffSize( nHandle )

cBuff := Space( nHandle )


IF nChr != InChr( nHandle, @cBuff, nChr )
MsgStop( 'Some kind of read failure on COM Port.' )
Return FALSE

ENDIF


// process data in cBuff

// write some stuff to port


IF ! OutChr( nHandle, cSomeStuff, Len( cSomeStuff ) )
MsgStop( 'Write error on COM Port.' )
Return FALSE

ENDIF


// ...etc

// and finally, when night is nigh...

// Close the port


UnInt_Port( nHandle )


Return NIL


Any further contributions to this library are most welcome.

Ned Robertson

XpertCTI, LLC

Richmond, VA  USA


July 21, 2003