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

Re: Looping a search and replacement

Expand Messages
  • silvermoonwoman2001
    ... ... Hi Patrick, Notetab clips let us goto labels, either because of a ^!Goto command or because tested conditions. The documentation entry on
    Message 1 of 3 , Aug 6, 2002
    • 0 Attachment
      --- In ntb-clips@y..., "Patrick-Julien Germain" <pjg@f...> wrote:
      <snip>

      > How can I write a loop searching for each occurrence and writing its
      > replacement text?
      >
      > I unsuccessfully searched the Help for loop or similar items--this
      > particular paragraph is meant for Sheri (=:
      >
      > Any idea or advice?
      >
      > Thanks in advance.
      >

      Hi Patrick,

      Notetab clips let us goto labels, either because of a ^!Goto command
      or because tested conditions. The documentation entry on Labels
      should be helpful.

      Meanwhile, try to learn by this example ;)

      You could add a ^!Jump Doc_Start before the :Start label; otherwise,
      it will run forward from the current cursor location until no more
      email addys are found, or until canceled.

      By the way I don't do HTML, so let me know if the attached works
      properly. I went strictly by your example, and because I read this
      forum at Yahoo, I couldn't even see the m e @ m y i s p . c o m <g>

      Regards,
      Sheri

      H="HTML ChartoDec Email Addys"
      ;08/06/2002 by Sheri Pierce
      :Start
      ^!Find "[A-Z_.-0-9]+@[A-Z_.-0-9]+" IRS
      ^!IfError End
      ;comment out the next 3 lines to avoid prompting
      ^!Set %doit%=^?{Encode All ^$GetSelection$?==_Yes|No}
      ^!IfCancel End
      ^!If ^%doit%="No" Start
      ^!Set %TarLength%=^$GetSelSize$
      ^!Set %Find%=^$GetSelection$
      ^!Set %Trans%=^%Empty%
      ^!Set %i%=0
      :LoopTarget
      ^!If ^%i%>^%TarLength% Out
      ^!Inc %i%
      ^!Append %Trans%=&#^$CharToDec(^$StrCopy("^$GetSelection$";^%i%;1)$)$;
      ^!Goto LoopTarget
      :Out
      ^!InsertSelect "^$StrDeleteRight("^%Trans%";3)$"
      ^!Set %Replace%=^$GetSelection$
      ^!Jump Select_End
      ^!Replace "^%Find%" >> "^%Replace%" AIS
      ^!Goto Start
      :End
      ^!ClearVariable %doit%
      ^!ClearVariable %TarLength%
      ^!ClearVariable %Find%
      ^!ClearVariable %Replace%
      ^!ClearVariable %Trans%
      ^!Prompt All Done
      ;end of clip
    Your message has been successfully submitted and would be delivered to recipients shortly.