home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 16 / CD_ASCQ_16_0994.iso / news / 4611 / fw16d.ins / SAMPLES / TESTCOMM.PRG < prev    next >
Text File  |  1994-05-18  |  2KB  |  54 lines

  1. // FiveWin - Windows Communications Sample
  2.  
  3. #include "FiveWin.ch"
  4.  
  5. //----------------------------------------------------------------------------//
  6.  
  7. function Main()
  8.  
  9.    local cDcb, nBytes
  10.    local nComm := OpenComm( "COM1", 1024, 128 )
  11.    local nError
  12.  
  13.    if ! BuildCommDcb( "COM1:2400,n,8,1", @cDcb )
  14.       nError = GetCommError( nComm )
  15.       MsgInfo( "BuildCommDcb Error: " + Str( nError ) )
  16.    endif
  17.  
  18.    if ! SetCommState( cDcb )
  19.       nError = GetCommError( nComm )
  20.       MsgInfo( "SetCommState Error: " + Str( nError ) )
  21.    endif
  22.  
  23.    if ( nBytes := WriteComm( nComm, "ATZ0" + Chr( 13 ) ) ) < 0
  24.       nError = GetCommError( nComm )
  25.       MsgInfo( "WriteComm Error: " + Str( nError ) )
  26.    else
  27.       // Windows requires to have a Window at least to perform comunications !!!
  28.       // Let's use the MessageBox() Window as default
  29.       MsgInfo( Str( nBytes ) + " bytes sent" )
  30.    endif
  31.  
  32.    if ( nBytes := WriteComm( nComm, "ATDT 2834830" + Chr( 13 ) ) ) < 0
  33.       nError = GetCommError( nComm )
  34.       MsgInfo( "WriteComm Error: " + Str( nError ) )
  35.    else
  36.       // Windows requires to have a Window at least to perform comunications !!!
  37.       // Let's use the MessageBox() Window as default
  38.       MsgInfo( Str( nBytes ) + " bytes sent" )
  39.    endif
  40.  
  41.    if FlushComm( nComm, 0 ) != 0
  42.       nError = GetCommError( nComm )
  43.       MsgInfo( "FlushComm Error: " + Str( nError ) )
  44.    endif
  45.  
  46.    if ! CloseComm( nComm )
  47.       nError = GetCommError( nComm )
  48.       MsgInfo( "CloseComm Error: " + Str( nError ) )
  49.    endif
  50.  
  51. return nil
  52.  
  53. //----------------------------------------------------------------------------//
  54.