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

[Clip] Using any clip with multiple documents

Expand Messages
  • Wayne VanWeerthuizen
    A common need mentioned on these lists is the ability to apply a clip to multiple documents at one time. This clip presents a menu where you can select any
    Message 1 of 1 , Mar 5 8:59 PM
    • 0 Attachment
      A common need mentioned on these lists is the ability to
      apply a clip to multiple documents at one time.

      This clip presents a menu where you can select any clip
      from any library. (The lists of clips will be updated
      and the prompt redisplayed, if you select a different
      library than the default. This is easiest if you
      double-click on a library.)

      It can then apply the clip to either all open documents,
      or all the documents in a folder. I do plan on improving
      it so that it will traverse directories recursively.



      H="Apply Clip To Multiple Documents"
      ; Apply Clip To Multiple Documents
      ;
      ; Author: Wayne VanWeerthuizen
      ; Email: wayne@...
      ; Homepage: http://landru.myhome.net/wayne
      ; Version: 1.0 beta 1
      ; Date: 2000-03-05

      :RePrompt
      ^!SetScreenUpdate OFF
      ^!SetWizardTitle "Choose Clip "
      ^!SetWizardLabel "Double click on a library (top) to update list of clips (bottom)"

      ^!SetListDelimiter |
      ^!SetArray %Libraries%=^$GetFiles("^$GetLibraryPath$";"*.clb";*;NAME)$

      ; Long line follows
      ^!IfTrue ^$IsEmpty(^%p_Library%)$ ^!Set %p_Library%="^$GetLibraryPath$^$GetLibraryName$"

      ^!Set %Libraries%=^$SetDefaultValue(^%Libraries%;^%p_Library%)$

      ^!Open ^%p_Library%
      ^!Jump Doc_Start
      ^!Select EOL
      ^!InsertText = V4 Outline MultiLine NoSorting TabWidth=30
      ^!Save AS "^$GetTempFile$"
      ^!Toolbar "Reload Document"
      ^!ClearVariable %Topics%
      ^!Set %Index%=1
      ^!Goto SkipAddBar
      :LoopGetTopics
      ^!Append %Topics%="|"
      :SkipAddBar
      ^!Set %OneTopic%="^$GetTopicName(^%Index%)$"
      ^!Append %Topics%="^%OneTopic%"
      ^!Inc %Index%
      ^!If ^%Index% <= ^$GetTopicCount$ LoopGetTopics
      ^!Close DISCARD

      ^!SET %QueryApply%="Apply the clip to=="
      ^!APPEND %QueryApply%="_All Open Documents ^=ALLOPEN|"
      ^!APPEND %QueryApply%="Files in a folder ^=FILES"

      ; Long line follows
      ^!Set %MyLib%="^?{(H=6)Choose Library==^%Libraries%}";%MyClip%="^?{(H=6)Choose Clip==^%Topics%}"; %APPLY%="^?{^%QueryApply%}"

      ^!IfError EXIT

      ^!IfSame "^%MyLib%" "^%p_Library%" SkipRepeat
      ^!Set %p_Library%=^%MyLib%
      ^!Goto RePrompt
      :SkipRepeat

      ^!SetScreenUpdate ON

      :SKIPSELTEXT
      ^!IFDIFF "^%APPLY%" "ALLOPEN" FILESINFOLDER

      ^!Document FIRST
      :DoSelTextLoop
      ^!IfTrue ^$IsClipDoc$ SkipThisDoc
      ^!If ^$GetSelSize$ < 1 ^!Select ALL
      ^!FarClip "^%p_Library%:^%MyClip"
      :SkipThisDoc
      ^!Document Next
      ^!IfError END
      ^!Goto DoSelTextLoop



      :FILESINFOLDER
      ; Long line follows
      ^!Set %FilesPath%="^?{(T=D)Select Folder Path}"; %FileSpec%="^?{File Specification=*.txt|*.htm|*.otl}"

      ^!IfCancel END
      ^!IfPathExist "^%FilesPath%" NEXT ELSE FILESINFOLDER
      ^!Set %ThisWildFile%="^$GetFileFirst(^%FilesPath%;"^%FileSpec%")$"

      :FilesInFolderLoop
      ^!IfTrue ^$IsEmpty("^%ThisWildFile%")$ Cleanup
      ^!Set %CloseMe%=0
      ^!IfTrue ^$IsOpen("^%ThisWildFile%")$ SKIP
      ^!Set %CloseMe%=1
      ^!Open "^%ThisWildFile%"
      ^!Select ALL
      ^!FarClip "^%p_Library%:^%MyClip"
      ^!IfFalse ^%CloseMe% SKIP
      ^!Close "^%ThisWildFile%" SAVE
      ^!Set %ThisWildFile%="^$GetFileNext$"
      ^!Goto FilesInFolderLoop

      :Cleanup
      ^!CloseFileFind
      ^!Goto END

      :END
      ; End of clip - "Apply Clip To Multiple Documents"


      --
      Wayne M. VanWeerthuizen
      Homepage: http://landru.myhome.net/wayne
    Your message has been successfully submitted and would be delivered to recipients shortly.