' Rapid-Q by William Yu (c)1999-2000 . ' ================================================================================ ' Upload_il_tuo_script_su_Rapidq.it ' Qcomport ****** QCOMPORT Component ****** QComPort provides an easy to use interface to communicate with the com ports. This component was made possible by Dejan Crnila. This component is currently being tested for stability, more functionality is expected in the future. Make sure to download the optional comport libraries to use this component. QComPort Properties Field Type R/W Default =================== =================== =================== =================== BaudRate INTEGER RW br110 Connected INTEGER R DataBits INTEGER RW 8 Handle INTEGER R InQue INTEGER R OutQue INTEGER R Parity INTEGER RW prNone PendingIO INTEGER R Port INTEGER RW 1 ReadBufSize INTEGER RW 1024 StopBits INTEGER RW sbOneStopBit WriteBufSize INTEGER RW 1024 QComPort Methods Method Type Description Params =================== =================== =================== =================== Aborts all AbortAllIO SUB asynchronous read/ 0 write operations Close SUB Closes 0 communication port Open SUB Opens communication 0 port Clears input buffer PurgeIn SUB and stops all input 0 functions Clears output PurgeOut SUB buffer and stops 0 all output functions SUB Read(QFile/ Reads stream data Read QMemoryStream, from com port, 3 Count%, Wait%) Count% < 32000 FUNCTION Returns a string ReadString ReadString$(Count%, representation 2 Wait%) bytes read from comport WaitForLastIO SUB Blocks until last 0 IO is completed SUB Write(QFile/ Writes stream to Write QMemoryStream, com port, Count% < 3 Count%, Wait%) 32000 WriteString SUB WriteString Writes string to 2 (Str$, Wait%) communication port QComPort Events Event Type Occurs when... Params =================== =================== =================== =================== A line break is detected, input and OnBreak VOID output is suspended 0 until break is cleared OnClose VOID Com port is closed 0 OnError VOID A line error occurs 0 OnOpen VOID Com port is 0 successfully opened A ring signal is OnRing VOID detected, used only 0 with modems. SUB (InQue AS A character(s) OnRxChar INTEGER) arrives in the 1 input buffer. OnTxEmpty VOID Output buffer is 0 flushed QComPort Examples $TYPECHECK ON CONST sbOneStopBit = 0 CONST prNone = 0 DECLARE SUB CommRxChar (InQue AS INTEGER) DECLARE SUB OpenClick DECLARE SUB SendClick DECLARE SUB FormClose DIM Comm AS QComPort Comm.OnRxChar = CommRxChar Comm.DataBits = 8 Comm.StopBits = sbOneStopBit Comm.Parity = prNone CREATE Form AS QFORM Caption = "Form1" Width = 302 Height = 240 Center CREATE Label1 AS QLABEL Caption = "Com Port:" Left = 5 Top = 9 Width = 51 END CREATE CREATE ComboBox1 AS QCOMBOBOX AddItems "COM1", _ "COM2", _ "COM3", _ "COM4" Left = 55 Width = 65 Top = 5 ItemIndex = 0 END CREATE CREATE ComboBox2 AS QCOMBOBOX AddItems "110", "300", "600", "1200", "2400", "4800", "9600", _ "14400", "19200", "38400", "56000", "57600", "115200" Left = 130 Width = 70 Top = 5 ItemIndex = 0 END CREATE CREATE OpenButton AS QBUTTON Caption = "&Open" Left = 210 Top = 4 OnClick = OpenClick END CREATE CREATE Edit1 AS QEDIT Text = "" Left = 12 Top = 40 Width = 186 END CREATE CREATE SendButton AS QBUTTON Caption = "&Send" Left = 210 Top = 38 Enabled = 0 OnClick = SendClick END CREATE CREATE RichEdit1 AS QRICHEDIT Left = 11 Top = 73 Width = 274 Height = 132 PlainText = 1 ReadOnly = 1 ScrollBars = 3 WordWrap = 0 END CREATE OnClose = FormClose END CREATE SUB OpenClick IF Comm.Connected THEN PRINT Comm.InQue EXIT SUB END IF Comm.Port = ComboBox1.ItemIndex + 1 Comm.BaudRate = ComboBox2.ItemIndex Comm.Open IF Comm.Connected THEN SendButton.Enabled = 1 ELSE ShowMessage("Cannot open port, try another") END IF END SUB SUB SendClick Comm.WriteString(Edit1.Text+CHR$(13)+CHR$(10), 1) Comm.WaitForLastIO END SUB SUB CommRxChar (InQue AS INTEGER) RichEdit1.AddStrings(Comm.ReadString(InQue, 1)) END SUB SUB FormClose IF Comm.Connected THEN Comm.Close END IF END SUB Form.ShowModal ' =============================================================================== ' 2003 Holyguard.net - 2007_Abruzzoweb