Loading ...
Sorry, an error occurred while loading the content.

16643Re: [Clip] Re: Creation of clip

Expand Messages
  • Don - HtmlFixIt.com
    Jun 19, 2007
      Give this a try (note one long line):
      ;clip to remove lines that do contain keywords
      ;keywords go in a file with one keyword per line
      ;start with the file to be parsed open
      ;whacked at by don at htmlfixit dot com
      ;used regex proposed by pat

      :StartOfClip
      ;long line follows
      ^!Set %Keywords%=^?{(T=O;F="Textfiles (*.txt)|*.txt")Choose Keyword File:}
      ;long line preceeds

      :GetKeywords
      ^!Open ^%Keywords%
      ; Remove empty lines in keyword list
      ^!Replace "(\r\n){2,}" >> "\r\n" AWRS
      ; Put keywords into alternation
      ^!Replace "\r\n" >> "|" AWRS
      ; Remove "empty alternation" at list end
      ^!Replace "\|\Z" >> "" AWRS
      ^!Select All
      ^!Set %Search%=^$GetSelection$
      ^!Close Discard

      ;be sure we are back on proper document
      ^!Set %Doc%=^$GetDocIndex$
      ^!SetWordWrap Off
      ^!Jump Doc_Start
      ^!SetDebug On


      :Loop
      ^!Select Eol
      ^!Find ".*(^%Search%).*" TIHRS
      ;this deletes line if contains keyword
      ^!IfError Continue
      ^!InsertText ^%EMPTY%
      ^!Goto Loop

      :Continue
      ;finish if end of file is reached
      ^!If ^$GetRow$ = ^$GetLinecount$ Finish
      ;this moves to next line if keyword not found
      ^!Jump +1
      ^!Goto Loop

      :Finish
      ;clean up empty line at start if exists
      ^!Jump Doc_Start
      ^!Select Eol
      ^!If "getselection" = "" Skip_2
      ^!SelectTo 2:1
      ^!InsertText ^%EMPTY%

      :EmptyLinesOut
      ;clean out all empty lines after deletion
      ^!Replace "^P^P" >> "^P" ACIWS
      ^!IfError End
    • Show all 30 messages in this topic