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

16658Re: Creation of clip

Expand Messages
  • Sheri
    Jun 22, 2007
    • 0 Attachment
      --- In ntb-clips@yahoogroups.com, "Flo" <flo.gehrke@...> wrote:
      > Sheri wrote...
      > > I haven't been following this thread in detail, but if he just wants
      > > to remove lines having a keyword, wouldn't it be better to use a
      > > replace command (replacing keyword lines with "") instead of using
      > > getdocmatchall?
      > Indeed - why not this way...
      > ^!SetScreenUpdate Off
      > ^!SetHintInfo Working...
      > ^!Set %Doc%=^$GetDocIndex$
      > ^!Set %Keywords%=^?[(T=O;F="Textfiles (*.txt)|*.txt")Choose Keyword
      > File:]
      > ^!Set %Case%=^?[Case-sensitive search:==Yes^=(?-i)|_No^=(?i)]
      > ^!Open ^%Keywords%
      > ^!Replace "(\r\n)+" >> "|" AWRS
      > ^!Replace "\|\Z" >> "" AWRS
      > ^!Replace "\A\|" >> "" AWRS
      > ^!Set %Search%=^$GetText$
      > ^!Close ^%Keywords% Discard
      > ^!SetDocIndex ^%Doc%
      > ^!Menu Edit/Copy All
      > ^!Menu Edit/Paste New
      > ^!Replace "^%Case%^.*(^%Search%).*\r\n" >> "" AWRS
      > ^!Info Finished!
      > Regards,
      > Flo

      Great! If interested in making further improvements, here are a few
      more enhancements to consider.

      When a clip makes use of the clipboard, its nice to restore its
      original contents at the end.

      You are closing the keyword document, before navigating to the
      original document. You need to be sure the keyword document was not
      already open when the clip was started. If it gets closed from a lower
      docindex than the starting document, you would not return to the
      original document when you set your docindex. You'd have to navigate
      to the original docindex and then close discard the keywords document.

      Normally it would be a good idea to reverse sort alternates when
      constructing a regular expression, but since whole lines containing
      alternates are being deleted, in this case that wouldn't make any
      difference. The reason they should normally be reverse sorted is,
      alternates are searched from left to right. If there's a keyword "be"
      and a keyword "before", "be|before" will never find "before" in the
      text. Using \b's before and after the alternates would also work, if
      the keywords are meant to be whole words only.

      If there are any characters that might get interpreted by the regex
      engine as metacharacters in the keyword document, they should be
      escaped with a backslash prior to using them in the alternates.

      When constructing a regular expression with code, its probably a good
      idea to check ^!IfRegexOK before using the expression in a "real"
      statement. If there is an error, you'd have an opportunity to show a
      message and still do clean up tasks (like restore the clipboard).

    • Show all 30 messages in this topic