Posted by: dertown
trouble skipping lines in a file - 12/08/05 11:38 AM
I am writing as script that will filter out unwatnted data in a report. Prevouldy it was just a continuous section that was needed. Now they would like the report filtered but there are more then one part the needs to be kept. These parts are seperated by unwanted data.
How do i skip the lines inbetween the two sections?
thank you for your help
How do i skip the lines inbetween the two sections?
Code:
'Variables for the file and stream Dim file, newFile, stream, strNew 'set the file object Set file = CreateObject("Scripting.FileSystemObject") 'set the stream and newFile as instances of the file object Set stream = file.OpenTextFile(PW_GetJobFilename) Set newFile = file.CreateTextFile("c:\me03c4\filter.txt") 'do loop to filter the last half of the file Do While strNew <> "CMP/DIV/LOC- 1 1 1 SALESREP-300 GODFATHERS D=SALES DOWN FROM PREVIOUS YEAR PERIOD" If strNew = "CMP/DIV/LOC- 1 1 1 SALESREP-180 COMPASS MNG HEALTH.LTC 13 D=SALES DOWN FROM PREVIOUS YEAR PERIOD" then Do While strNew <> "CMP/DIV/LOC- 1 1 1 SALESREP-182 MORRISON'S MANAGE ACUTE13 D=SALES DOWN FROM PREVIOUS YEAR PERIOD" strNew = stream.ReadLine newFile.WriteLine strNew Loop Elseif strNew = "CMP/DIV/LOC- 1 1 1 SALESREP-200 MARITA DELOBELLE D=SALES DOWN FROM PREVIOUS YEAR PERIOD" then Do While strNew <> "CMP/DIV/LOC- 1 1 1 SALESREP- SALESREP-300 GODFATHERS D=SALES DOWN FROM PREVIOUS YEAR PERIOD" strNew = stream.ReadLine newFile.WriteLine strNew Loop Else stream.SkipLine strNew = stream.ReadLine End if Loop 'closes the stream stream.Close