I'm also collecting the first line of any warnings or errors found in the output into an array in order to display an error/warning summary to the user once the log is done being printed to the textbox. The resulting code looks like this:
oInFile = oInFileO.OpenTextFile(chrDrive & ":\SASH2\Log.log", IOMode.ForReading)
strSText = ""
Do While Not oInFile.AtEndOFStream
If strSText Like "ERROR:*" Then
aryErrors.Add(strSText)
With frmSAS.txtLog
.Selectionstart = .TextLength
.SelectionColor = Color.Red
.AppendText(strSText & vbNewLine)
.SelectionColor = .ForeColor
End With
strSText = oInFile.Readline
If Len(strSText) > 5 Then
Do While strSText Like " *" And Not oInFile.AtEndOFStream
With frmSAS.txtLog
.Selectionstart = .TextLength
.SelectionColor = Color.Red
.AppendText(strSText & vbNewLine)
.SelectionColor = .ForeColor
End With
strSText = oInFile.Readline
Loop
End If
ElseIf strSText Like "NOTE:*" Then
With frmSAS.txtLog
.Selectionstart = .TextLength
.SelectionColor = Color.Blue
.AppendText(strSText & vbNewLine)
.SelectionColor = .ForeColor
End With
strSText = oInFile.Readline
If Len(strSText) > 5 Then
Do While strSText Like " *" And Not oInFile.AtEndOFStream
With frmSAS.txtLog
.Selectionstart = .TextLength
.SelectionColor = Color.Blue
.AppendText(strSText & vbNewLine)
.SelectionColor = .ForeColor
End With
strSText = oInFile.Readline
Loop
End If
ElseIf strSText Like "WARNING:*" Then
aryErrors.Add(strSText)
With frmSAS.txtLog
.Selectionstart = .TextLength
.SelectionColor = Color.Green
.AppendText(strSText & vbNewLine)
.SelectionColor = .ForeColor
End With
strSText = oInFile.Readline
If Len(strSText) > 5 Then
Do While strSText Like " *" And Not oInFile.AtEndOFStream
With frmSAS.txtLog
.Selectionstart = .TextLength
.SelectionColor = Color.Green
.AppendText(strSText & vbNewLine)
.SelectionColor = .ForeColor
End With
strSText = oInFile.Readline
Loop
End If
Else
With frmSAS.txtLog
.Selectionstart = .TextLength
.SelectionColor = Color.Black
.AppendText(strSText & vbNewLine)
.SelectionColor = .ForeColor
End With
strSText = oInFile.Readline
End If
Loop
oInFile.Close()
Surely there's a better solution than this mess! I've attached a SAS log file like one I'd be reading in if anyone wants to give it a try (please note there are an enormous number of errors and warnings in the log file; I did that on purpose so I'd have a diverse log file to work with). I'd appreciate any insight you guys might have.
Attached File(s)
-
Log.txt (20.91K)
Number of downloads: 22

New Topic/Question
Reply




MultiQuote




|