Would you be able to help me figure out/make pretty my code? I have a file I need to edit and save some of it to next file. Saving is not an issue here, only editing. I need to skip 2 lines and read next 30 or so to memory. Until now I've been using:
Const ForReading = 1
Const ForWriting = 2
set WshShell = WScript.CreateObject("WScript.Shell")
strMyDocs = WshShell.SpecialFolders("MyDocuments")
strDesktop = WshShell.SpecialFolders("Desktop")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strDesktop & "\folder\blabla.vbs", ForReading)
strText = objFile.SkipLine & objFile.SkipLine
strText = objFile.ReadLine & vbNewLine & objFile.ReadLine & vbNewLine &
objFile.ReadLine & vbNewLine & objFile.ReadLine & vbNewLine & objFile.ReadLine &
vbNewLine & objFile.ReadLine & vbNewLine &_
objFile.ReadLine & vbNewLine & objFile.ReadLine & vbNewLine & objFile.ReadLine &
vbNewLine & objFile.ReadLine & vbNewLine & objFile.ReadLine & vbNewLine &
objFile.ReadLine & vbNewLine & objFile.ReadLine & vbNewLine &_
objFile.ReadLine & vbNewLine & objFile.ReadLine & vbNewLine & objFile.ReadLine &
vbNewLine & objFile.ReadLine & vbNewLine & objFile.ReadLine & vbNewLine &
objFile.ReadLine & vbNewLine & objFile.ReadLine & vbNewLine &_
objFile.ReadLine & vbNewLine & objFile.ReadLine & vbNewLine & objFile.ReadLine &
vbNewLine & objFile.ReadLine & vbNewLine & objFile.ReadLine & vbNewLine &
objFile.ReadLine & vbNewLine & objFile.ReadLine & vbNewLine & objFile.ReadLine
objFile.Close
...
As you can see it looks pretty lame, it does the job though. I was able to find something to replace skilLine part:
For a = 1 to 30
If ((a =< 2) And (ObjFile.AtEndOfStream <> True)) Then
objFile.SkipLine
Do Until a = 30
objFile.ReadLine
Loop
Else
objFile.Close
End If
but cannot find a way to read next 28lines. I tried a lot and it always reads 28 lines but starting with line 31, not 3.
Could you help me?
Thanks