Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Comm : how to capture the output per line

Status
Not open for further replies.

vpaladan

Programmer
Nov 13, 2002
13
PH
Good Day to all:

Im new in VB and im trying to develop a call accounting system that will read the output of a Nortel PABX through the Comm.

I used mscomm to listen. My problem is that i want to read my mscomm.input per line or until it encounters a carriage return. (please note that input/no. of characters are not constant).

I've read already about fgets (visual foxpro) but how can i apply if it is applicable. kindly advise.

Thanks,

Vic

 
Hi Vic,

One way to do this is shown in the example below.
mscomm is the MsComm object placed on a Form and assuming the Port is succesfully opened

#DEFINE CR CHR(13)

oCom = thisform.mscomm

llQuit = .f.
llReceived = .f.
lcReceiveChar = ''
lcReceiveString = ''

do while !llQuit and !llReceived
if oCom.inBufferCount>0
lcReceiveChar = oCom.input
*-- Check if Carriage Return is received
if lcReceiveChar=CR
llReceived = .t.
else
lcReceiveString = lcReceiveString + lcReceiveChar
endif
endif
if chrsaw()
*-- Quit if user presses Escape
llQuit = (inkey()=27)
endif
enddo

Regards,
André
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top