by tnhoe » Tue Jun 06, 2006 5:14 pm
Try this :-
function fLptSend
local cDcb, nBytes
local nComm := OpenComm( 'LPT1', 1200, 128 )
local nError
if ! BuildCommDcb( "LPT1:1200,n,8,1", @cDcb )
nError = GetCommError( nComm )
Msgwait( " BuildCommDcb Error: " + Str( nError ),'',.3 )
endif
if ! SetCommState( cDcb )
nError = GetCommError( nComm )
Msgwait( "SetCommState Error: " + Str( nError ),'',.3 )
return .t.
endif
if ( nBytes := WriteComm( nComm, 'your ASCII string') ) < 0
nError = GetCommError( nComm )
Msgwait( "WriteComm Error: " + Str( nError ),'',.1 )
else
Msgwait('Sent !!!',.1 )
endif
if FlushComm( nComm, 0 ) != 0
nError = GetCommError( nComm )
Msgwait( " FlushComm Error: " + Str( nError ),'',.01 )
endif
if ! CloseComm( nComm )
nError = GetCommError( nComm )
Msgwait( "CloseComm Error: " + Str( nError ),'',.01 )
endif
return nil