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

Thanks Jody, Great Help

Expand Messages
  • Alan Williams
    Hi ntb-clips, I wrote ... Jody supplied a beautiful answer. (See Below Sig Line) However I have a question. Jodys Clip behaves in an intersting fashion. If I
    Message 1 of 2 , May 3, 2000
    • 0 Attachment
      Hi ntb-clips,

      I wrote
      > Im trying to write a clip that will open each file in a
      > directory, insert a file at a marker, do a find and replace
      > using regular expression (am unable to get it to be non-greedy
      > or whatever).

      Jody supplied a beautiful answer. (See Below Sig Line)

      However I have a question. Jodys Clip behaves in an intersting
      fashion. If I wish to include in the replace label part additional
      actions, such as insertfile at top, then a jump text_end insertfile
      anotherfile, the clip runs through all files in the directory
      performing the regex replace, but only performs the insertfile actions
      on the last file!??

      In this case the Insertfile actions come in the clip before the regex
      replace, So it appears in the case of the first two files (in test dir
      of three files)that the insertfile action is ignored while the regex
      replace is honoured, but all actions are performed on the last file.

      Why would this be so?


      Best regards,
      Alan
      mailto:alwilli@...


      <--- Copy below this line --->
      H=OpenDir-RegExp-G
      ; Last Updated 05/03/2000, Sojourner@..., jody
      ; Requires NoteTab v4.81
      ; http://www.sureword.com/notetab

      ^!ClearVariables

      ; long line till blank line
      ^!Set %Folder%=^?{(T=D)Full path, end in backslash=E:\NoteTab Pro\Test\}; %Type%=^?{File
      &Type=*.htm*}; %Sort%=^?{&Sort order=Date|_Name|Size|Type|UnSorted}

      ^!SetHintInfo Opening Files...

      ^!SetListDelimiter ^p
      ^!SetArray %OpenList%=^$GetFiles("^%Folder%";^%Type%;^%Sort%)$
      ^!Set %Count%=^%OpenList0%
      ^!Set %Index%=0
      ^!Set %OpenCount%=0

      :OpenLoop
      ^!SetScreenUpdate Off
      ^!Inc %Index%
      ^!If ^%Index% > ^%Count% Replace
      ^!IfTrue ^%FileCnt% Skip
      ^!Open ^%OpenList^%Index%%
      ^!Goto OpenLoop

      :Replace
      ; change the replace side
      ^!Replace "<!--[^>]*-->" >> "<!-- www.sureword.com/notetab -->" WATIRSG
      ^!IfError End

      <--- Copy above this line, right --->
      <--- click over a Library, and --->
      <--- choose "Add from Clipboard" --->
    • Jody
      Hi Alan, ... You need to put your InsertFile into the OpenFile loop if I understand - which I don t - I m just guessing. The following will insert a file at
      Message 2 of 2 , May 3, 2000
      • 0 Attachment
        Hi Alan,

        > However I have a question. Jodys Clip behaves in an intersting
        > fashion. If I wish to include in the replace label part
        > additional actions, such as insertfile at top, then a jump
        > text_end insertfile anotherfile, the clip runs through all
        > files in the directory performing the regex replace, but only
        > performs the insertfile actions on the last file!??

        You need to put your InsertFile into the OpenFile loop if I
        understand - which I don't - I'm just guessing. The following
        will insert a file at the top and bottom of each file that is
        open. (I took a variable out from the script I copied the code
        from in my DirStuff. ;)

        :OpenLoop
        ^!SetScreenUpdate Off
        ^!Inc %Index%
        ^!If ^%Index% > ^%Count% Replace
        ^!Open ^%OpenList^%Index%%
        ^!Insert ^p^p
        ^!InsertFile "..\Path\Filename.ext"
        ^!Insert ^p
        ^!Jump Doc_End
        ^!InsertFile "..\Path\Filename.ext"
        ^!Goto OpenLoop

        Happy Clip'n!
        Jody

        http://www.sureword.com/notetab

        Subscribe, UnSubscribe, Options
        mailto:Ntb-Clips-Subscribe@...
        mailto:Ntb-Clips-UnSubscribe@...
        http://www.egroups.com/list/ntb-clips
      Your message has been successfully submitted and would be delivered to recipients shortly.