Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ANSI escape characters...TOO SLOW help! 1

Status
Not open for further replies.

rjr9999

Programmer
Apr 7, 2001
183
US
Ok, here's the deal...I'm writing a telnet application, and I'm using a rich text box for the output. My problem is with the Ansi escape characters for color, etc.
eg. "[31m" = text color red. The method I'm using now consists of grabing the data, putting it in an array. I then post data to the text box from that array, unless I hit an escape character, at which point I mark the location within the text, and the process the escape sequence preforms (colors, in most cases). Then continue printing, untill the next escape character and so on. After this, I will use text.selstart = Location Text.selcolor = Location's color, and repeat this for each location...my problem here is, obviously, that it's a very slow process, and the code is very tedious. My question is, is there a different form object (text box) I can use that either automatically recognizes the escape characters, or is there another way I can do this to make the program run faster?

Any help is appriciated,
Rob
 
"Post" to an array?
Set .Selxxx "on the fly"
'Mid$, Left$, Split$ are faster
' Produce string instead of Variant string
Code:
Dim aryText() as string
Dim lngColor  as long
Dim StrFont   as string
Dim J         as long
aryText = Split$(strText,"[") ' 
With rtb
.SelColor = Rgb (0,0,0) ' Defualt .SelColor
.SelStart = 0
[code]
For I = 0 To UBound(aryText)
    J = 1
    If Left$(aryText(I),1) = "[" then
        Select Case
        ...'Process ANSI - 
            J = 1st real character in item
        End Select
        .SelColor = lngColor
        .SelFont  = strFont
    End if
    .SelStart = 99999999 ' Set to last char + 1 
    .SetRtf = Mid$(aryText(I),J)
Next
End With
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top