IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#19006 - 12/08/05 11:38 AM trouble skipping lines in a file
dertown Offline
Member

Registered: 11/15/05
Posts: 31
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?

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 
thank you for your help

Top
#19007 - 12/14/05 10:32 AM Re: trouble skipping lines in a file
dertown Offline
Member

Registered: 11/15/05
Posts: 31
Hey

I just figured this out. if you want i post the corrected code.

it was a bunch ofstupid errors on my part

Top