1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| Option Explicit
Const ForReading = 1
Const ForWriting = 2
Dim fso, fichLog, Ret, tmp, FichResult
Set fso = CreateObject("Scripting.FileSystemObject")
Set fichLog = fso.OpenTextFile("Logfile.log", ForReading, False)
Ret = ""
Set FichResult = fso.OpenTextFile("Resultat.log", ForWriting, True)
Do While Not fichLog.AtEndOfStream
tmp = fichLog.ReadLine
If tmp <> "" Then
MsgBox EntreLimites(tmp)
FichResult.WriteLine EntreLimites(tmp) ' On consigne le résultat dans fichier !
End If
Loop
FichLog.Close
FichResult.Close
' =========================
Function EntreLimites(strIn)
Dim temp, I, retVal, PosDebut, PosFin
PosDebut = InStr(1, strIn, "<![LOG", vbTextCompare) ' On peut se passer de cette instruction et
' la remplacer par 1 dans la boucle For ...To
' puisqu'on est au début de la ligne(sauf mention contraire)
PosFin = InStr(1, strIn, "LOG]!>", vbTextCompare)
temp = ""
For I = PosDebut To PosFin + 5 ' +5 sinon on s'arrêtera à la lettre L de "LOG]!>"
temp = temp & Mid(strIn, I, 1)
Next
EntreLimites = temp
End Function |
Partager