Page 1 of 1

Select all lines from the start... and delete them all

Posted: Sun Oct 08, 2006 5:59 pm
by kobong
Hello

I have filter:

“Select all lines from the start of the file until a line starting with DeliveredDate:”

My question is: how to delete all matching lines (instead of changing them into upper case - as is default now).

I've used subfilter Remove all, but it doesn't work. So: how to delete all matching (to the line: "DeliveredDate:") lines?

Please, give me filter:

“DELETE all lines from the start of the file until a line starting with DeliveredDate:”

Best regards!
Peter

Posted: Mon Oct 09, 2006 8:51 am
by DataMystic Support
Did you add this as a subfilter, or just below the select filter? Please email us your filter, or read the help on creating subfilters.

Posted: Mon Oct 09, 2006 2:12 pm
by kobong
Hello!

First, I use normal Your VBScript script:

Code: Select all

Filter List
-----------
|--VBScript script  Timeout: 10000 milliseconds
|  |  'Select all lines from the start of the file until a line starting with DeliveredDate:
|  |  
|  |  dim textFound
|  |  
|  |  'Called for every line in the file
|  |  'EOL contains the end of line characters (Unix, DOS or Mac) that must be
|  |  'appended to each line
|  |  function processLine(line, EOL)
|  |  
|  |    if InStr( line, "DeliveredDate:" ) = 1 then
|  |      textFound = true
|  |    end if
|  |  
|  |    if not( textFound ) then
|  |      processLine = TextPipe.subFilterEntireText(line) & EOL
|  |    else
|  |      processLine = line & EOL
|  |    end if
|  |  
|  |  end function
|  |  
|  |  
|  |  'Called before each file is opened -
|  |  'perform per-file initialisation here
|  |  function startFile()
|  |    textFound = false
|  |    startFile = ""
|  |  end function
|  |  
|  |  
|  |  'Called before each file is closed -
|  |  'flush all pending file output here
|  |  function endFile()
|  |    endFile = ""
|  |  end function
|  |  
|  |  
|  |  'Called at the start of a processing job -
|  |  'perform one-time initialisation here
|  |  sub startJob()
|  |    'do nothing
|  |  end sub
|  |  
|  |  
|  |  'Called at the end of a processing job -
|  |  'destroy any declared objects here
|  |  sub endJob()
|  |    'do nothing
|  |  end sub
|  |  
|  |  
|  |
|  +--Convert to UPPERCASE [THERE IS THE CRUCIAL ELEMENT]
|      
+--Output to file(s)

But, please, tell me, what kind of (sub)filter - (sub)command - should I use (instead of default: Convert to UPPERCASE) in order to DELETE all matching lines, it is: form the start of the file until a line starting with DeliveredDate:

Thank You in advance!
Peter

Posted: Mon Oct 09, 2006 8:09 pm
by DataMystic Support
That VBScript code will not work.

Use this simple search/replace filter instead:

Code: Select all

Perl pattern [(.*)(^DeliveredDate:)] with [$2]
   [ ] Match case
   [ ] Whole words only
   [ ] Case sensitive replace
   [ ] Prompt on replace
   [ ] Skip prompt if identical
   [ ] First only
   [ ] Extract matches
   Maximum text buffer size 409600
   [ ] Maximum match (greedy)
   [ ] Allow comments
   [X] '.' matches newline
   [ ] UTF-8 Support
 

Posted: Tue Oct 10, 2006 3:35 pm
by kobong
Thank You, it works indeed, but by the use of the filter:

“select from start to matching line.fll”

tasks could by done more sophisticated, even: faster.

The one thing what the User need is filter:

“remove from start to matching line.fll”

(and – prospectively: “remove from matching line to the end of file.fll”)

but today (7.6.1) there is no such filter(s).

Anyway: Your regex-tip is working. Thank you once more!

Bye, bye.

Posted: Wed Oct 11, 2006 10:45 am
by DataMystic Support
Thanks - we'll include those in the next release