Code: Select all
/*----------------------------------------------------------------------------------------------------*/
STATIC FUNCTION ReadBufferComm( oLector, oBarra )
LOCAL oDlg, oLbx
LOCAL hDatos, nBytes, cBuffer, cLinea, aRecords, nRecCount
LOCAL lPrimeraVez, cBuffTemp, nPos
hDatos:= OutChr( "("+ oLector:ps_NOSERIE + ",kqdata)" )
cBuffer:= ""
nBytes := 200
cLinea := ""
aRecords:= {}
lPrimeraVez:= .T.
DO WHILE .T.
nBytes := InbufSize()
cBuffer:= InChr( nBytes )
IF At( "kqdata,ok", cBuffer ) > 0
IF lPrimeraVez
cBuffTemp:= cBuffer
cBuffTemp:= SubStr( cBuffTemp, 1, 22 )
nRecCount:= Val( SubStr( cBuffTemp, 16, 6 ) )
lPrimeraVez:= .F.
oBarra:SetRange( 1, nRecCount )
ENDIF
ENDIF
IF At( "kqdataend,ok", cBuffer ) > 0
IF Len( AllTrim( cBuffer ) ) > 0
cLinea+= BufferClean( cBuffer )
aRecords:= str2a ( cLinea, CRLF )
oBarra:SetPos( Len( aRecords ) ) // Aqui se supone que actualiza la barra de progreso
SysRefresh()
ENDIF
EXIT
ELSE
IF Len( AllTrim( cBuffer ) ) > 0
cLinea+= BufferClean( cBuffer )
aRecords:= str2a ( cLinea, CRLF )
oBarra:SetPos( Len( aRecords ) )
SysRefresh()
ENDIF
ENDIF
SysRefresh()
cBuffer:= ""
ENDDO
RETURN NIL