'************************************************** 'Adds data to the Term control's .Text property. 'Also filters control characters such as Back Space 'Charriage Return and Line Feed, and writes data to 'an open log file. ' 'Back Space chars. delete the character to the left, 'either in the .Text property, or the passed string. 'Line Feed characters are appended to all Charriage 'Returns. The size of the Term control's Text 'property is also monitored so that it never 'excedes 16384 characters. '************************************************** ' Static Sub ShowData (Term As Control, Dta$) On Error Resume Next Dim Nd, I '--- Make sure the existing text doesn't get ' too large. Nd = Len(Term.Text) If Nd >= 16384 Then Term.Text = Mid$(Term.Text, 4097) Nd = Len(Term.Text) End If '--- Point to the end of Term's data Term.SelStart = Nd '--- Filter/handle Back Space characters Do I = InStr(Dta$, Chr$(8)) If I Then If I = 1 Then Term.SelStart = Nd - 1 Term.SelLength = 1 Dta$ = Mid$(Dta$, I + 1) Else Dta$ = Left$(Dta$, I - 2) + Mid$(Dta$, I + 1) End If End If Loop While I '--- Elliminate Line Feeds (put back below) Do I = InStr(Dta$, Chr$(10)) If I Then Dta$ = Left$(Dta$, I - 1) + Mid$(Dta$, I + 1) End If Loop While I '--- Make sure all Charriage Returns have a ' Line Feed I = 1 Do I = InStr(I, Dta$, Chr$(13)) If I Then Dta$ = Left$(Dta$, I) + Chr$(10) + Mid$(Dta$, I + 1) I = I + 1 End If Loop While I '--- Add the filtered data to .Text Term.SelText = Dta$ '--- Log data to file if requested If hLogFile Then I = 2 Do Err = 0 Put hLogFile, , Dta$ If Err Then I = MsgBox(Error$, 21) If I = 2 Then MCloseLog_Click End If End If Loop While I <> 2 End If End Sub