Ok, maybe I'm just tired or something, but this looks like it should work perfectly to me. The object is, it will read the text (strData) it will then extract escape codes, marking them at the same time (this part works fine). It is then supposed to display the color starting from where the escape code pointed and ending with the next escape code, unless it's a modifier. The problem here, is unfortunately, it doesn't display the color...WHY? Any help is always appriciated
Good luck, you'll probably need it
.
Code to follow
-----------------------------------------------------------
ascChar(1) = "[0m" ' Normal Display
ascChar(2) = "[1m" ' Bold On
ascChar(3) = "[4m" ' Underline
ascChar(4) = "[5m" ' Blink On
ascChar(5) = "[7m" ' Reverse Video
ascChar(6) = "[8m" ' Invisible
ascChar(7) = "[30m" ' Black Text
ascChar(8) = "[31m" ' Red Text
ascChar(9) = "[32m" ' Green Text
ascChar(10) = "[33m" ' Yellow Text
ascChar(11) = "[34m" ' Blue text
ascChar(12) = "[35m" ' Magenta Text
ascChar(13) = "[36m" ' Cyan Text
ascChar(14) = "[37m" ' White Text
ascChar(15) = "[40m" ' Black BG
ascChar(16) = "[41m" ' Red BG
ascChar(17) = "[42m" ' Green BG
ascChar(18) = "[43m" ' Yellow BG
ascChar(19) = "[44m" ' Blue BG
ascChar(20) = "[45m" ' Magenta BG
ascChar(21) = "[46m" ' Cyan BG
ascChar(22) = "[47m" ' White BG
ascChar(23) = "[1;30m" ' Black Text (Bright)
ascChar(24) = "[1;31m" ' Red Text (Bright)
ascChar(25) = "[1;32m" ' Green Text (Bright)
ascChar(26) = "[1;33m" ' Yellow Text (Bright)
ascChar(27) = "[1;34m" ' Blue text (Bright)
ascChar(28) = "[1;35m" ' Magenta Text (Bright)
ascChar(29) = "[1;36m" ' Cyan Text (Bright)
ascChar(30) = "[1;37m" ' White Text (Bright)
Dim found As Long
Dim lastFound As Long
Dim strStart(1 To 10000) As Long
Dim strColor(1 To 10000) As Integer
Dim cutout(1 To 10000) As Long
Dim strOn As Long
Dim aryText() As String
Dim strOut As String
cutout(1) = 0
' Mark escape codes
For I = 1 To UBound(ascChar)
found = 1
lastFound = 1
strOn = 1
Do While found <> 0
found = InStr(lastFound, strData, ascChar(I))
If found <> 0 Then
lastFound = found + 1
strStart(strOn) = found
strColor(strOn) = I
Select Case I
Case 1 To 6
cutout(strOn) = cutout(strOn) - 4
Case 7 To 22
cutout(strOn) = cutout(strOn) - 5
Case Else
cutout(strOn) = cutout(strOn) - 7
End Select
strOn = strOn + 1
End If
Loop
Next
' Extract escape codes
strOut = strData
For X = 1 To UBound(ascChar)
aryText = Split(strOut, ascChar(X))
For I = 0 To UBound(aryText)
If I = 0 Then
strOut = Mid(aryText(I), 1)
Else
strOut = strOut & Mid(aryText(I), 1)
End If
Next
Next
' Print the output
Text1.SelStart = 66000
Text1.SelText = strOut
' Display the colors
For I = 1 To (strOn - 1)
Select Case strColor(I)
' I didn't add all of them yet, just for testing
' purposes...but don't worry, that's not the
' problem
Case 13
Text1.SelStart = strStart(I)
Text1.SelLength = 65000
Text1.SelColor = vbBlue
Case 9
Text1.SelStart = strStart(I)
Text1.SelLength = 65000
Text1.SelColor = vbGreen
End Select
Next I
End Sub
-----------------------------------------------------------
Rob
"Programming is like art...It makes me feel like chopping my ear off."
Code to follow
-----------------------------------------------------------
ascChar(1) = "[0m" ' Normal Display
ascChar(2) = "[1m" ' Bold On
ascChar(3) = "[4m" ' Underline
ascChar(4) = "[5m" ' Blink On
ascChar(5) = "[7m" ' Reverse Video
ascChar(6) = "[8m" ' Invisible
ascChar(7) = "[30m" ' Black Text
ascChar(8) = "[31m" ' Red Text
ascChar(9) = "[32m" ' Green Text
ascChar(10) = "[33m" ' Yellow Text
ascChar(11) = "[34m" ' Blue text
ascChar(12) = "[35m" ' Magenta Text
ascChar(13) = "[36m" ' Cyan Text
ascChar(14) = "[37m" ' White Text
ascChar(15) = "[40m" ' Black BG
ascChar(16) = "[41m" ' Red BG
ascChar(17) = "[42m" ' Green BG
ascChar(18) = "[43m" ' Yellow BG
ascChar(19) = "[44m" ' Blue BG
ascChar(20) = "[45m" ' Magenta BG
ascChar(21) = "[46m" ' Cyan BG
ascChar(22) = "[47m" ' White BG
ascChar(23) = "[1;30m" ' Black Text (Bright)
ascChar(24) = "[1;31m" ' Red Text (Bright)
ascChar(25) = "[1;32m" ' Green Text (Bright)
ascChar(26) = "[1;33m" ' Yellow Text (Bright)
ascChar(27) = "[1;34m" ' Blue text (Bright)
ascChar(28) = "[1;35m" ' Magenta Text (Bright)
ascChar(29) = "[1;36m" ' Cyan Text (Bright)
ascChar(30) = "[1;37m" ' White Text (Bright)
Dim found As Long
Dim lastFound As Long
Dim strStart(1 To 10000) As Long
Dim strColor(1 To 10000) As Integer
Dim cutout(1 To 10000) As Long
Dim strOn As Long
Dim aryText() As String
Dim strOut As String
cutout(1) = 0
' Mark escape codes
For I = 1 To UBound(ascChar)
found = 1
lastFound = 1
strOn = 1
Do While found <> 0
found = InStr(lastFound, strData, ascChar(I))
If found <> 0 Then
lastFound = found + 1
strStart(strOn) = found
strColor(strOn) = I
Select Case I
Case 1 To 6
cutout(strOn) = cutout(strOn) - 4
Case 7 To 22
cutout(strOn) = cutout(strOn) - 5
Case Else
cutout(strOn) = cutout(strOn) - 7
End Select
strOn = strOn + 1
End If
Loop
Next
' Extract escape codes
strOut = strData
For X = 1 To UBound(ascChar)
aryText = Split(strOut, ascChar(X))
For I = 0 To UBound(aryText)
If I = 0 Then
strOut = Mid(aryText(I), 1)
Else
strOut = strOut & Mid(aryText(I), 1)
End If
Next
Next
' Print the output
Text1.SelStart = 66000
Text1.SelText = strOut
' Display the colors
For I = 1 To (strOn - 1)
Select Case strColor(I)
' I didn't add all of them yet, just for testing
' purposes...but don't worry, that's not the
' problem
Case 13
Text1.SelStart = strStart(I)
Text1.SelLength = 65000
Text1.SelColor = vbBlue
Case 9
Text1.SelStart = strStart(I)
Text1.SelLength = 65000
Text1.SelColor = vbGreen
End Select
Next I
End Sub
-----------------------------------------------------------
Rob
"Programming is like art...It makes me feel like chopping my ear off."