Hi
I’m just getting back into Xojo after a while, trying to load a log file and display it in a list box with colour coded rows.
I’ve got the log file loaded into an array and can populate the listbox but in the CellBackgroundPaint event am unable to get the value of one of the cells ( INFORMATION, WARNING, ERROR).
In the code below, the debugger shows that the String 'logType 'is showing as INFORMATION, but the integer ‘deleteInteger’ is always coming up as -1, and so the cells never actually get assigned a colour because none of the Cases are greater than -1.
Can anyone see where I’m going wrong.
#Pragma Unused column
If row >= Me.RowCount Then Return False
Var logType As String = me.CellValueAt(row,1)
var deleteInteger as Integer = logType.indexOf("INFORMATION") //variable for debugging only
Select Case true
case logType.indexOf("INFORMATION") >= 0
g.AntiAlias = False
g.DrawingColor = &cb2e89b
g.FillRectangle(0,0, g.Width, g.Height)
case logType.indexOf("INFO") >= 0
g.AntiAlias = False
g.DrawingColor = &cb2e89b
g.FillRectangle(0,0, g.Width, g.Height)
case logType.indexOf("DEBUG") >= 0
g.AntiAlias = False
g.DrawingColor = &cafcced
g.FillRectangle(0,0, g.Width, g.Height)
case logType.indexOf("WARNING") >= 0
g.AntiAlias = False
g.DrawingColor = &ced9f64
g.FillRectangle(0,0, g.Width, g.Height)
case logType.indexOf("ERROR") >= 0
g.AntiAlias = False
g.DrawingColor = &ceb827f
g.FillRectangle(0,0, g.Width, g.Height)
end Select
Return True
Thanks Jeff
I already tried defining the string manually like you suggested and it does give me the result I’m after.
When I run my code as is, and have a break point just before the select case, the debugger shows logType is INFORMATION.
I have also tried to force the encoding, I do that when I create the array.
Best guess: this is a UTF-16 string that was defined as UTF-8 and the extra bytes are nulls between the characters. If it’s anything like that, you should fix it at its source, not in this method.
Thanks for your help everyone, the original file that I was reading was a UTF16LE, changed the encoding of the text input stream and all is working now.