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

Re: Clip: Save Search & Replace as clip

Expand Messages
  • Sheri
    Hi Alan, Just when I thought I resolved the vertical bar problem I discovered the clip wasn t working as well as I first thought. It didn t like tokens e.g.,
    Message 1 of 10 , Jul 3, 2002
    • 0 Attachment
      Hi Alan,

      Just when I thought I resolved the vertical bar problem I discovered the clip
      wasn't working as well as I first thought. It didn't like tokens e.g., ^P, in
      retrieved s/r texts. However they worked fine in newly typed s/r text.

      Here is revised version that might solve all the problems but I make no guarantees <g>

      When the retrieved s/r text had "|" characters, they now show up as ^%VBAR%, but
      so far that seems to function equivalently in the ^!Replace command.

      Regards,
      Sheri

      This clip can be viewed and copied without linebreaks at:

      http://groups.yahoo.com/group/ntb-clips/messages/8733?viscount=-2&expand=1


      H="Revised Enhanced Replace"
      ;need to save ini or most recent search/replace texts are not in them
      ^!ProgIniSave
      ^!ClearVariables
      ^!Set %SrchLstCnt%=^$GetValue("ReplaceDialog:SearchListCount")$
      ^!Set %count%=0
      ; above and next loop gathers "find what" items from ini
      :srchliscnt
      ^!Inc %count%
      ^!If ^%count% > ^%SrchLstCnt% slc_exit
      ^!SetCode %srchitem%=^$UseTokens(^$GetValue("ReplaceDialog:SearchList_^%count%")$)$
      ^!SetCode %srchlist%=^%srchlist%~OR~^%srchitem%
      ^!Goto srchliscnt
      :slc_exit
      ^!Set %RplcLstCnt%=^$GetValue("ReplaceDialog:ReplaceListCount")$
      ^!Set %count%=0
      ; above and next loop gathers "replace with" items from ini
      :rplcliscnt
      ^!Inc %count%
      ^!If ^%count% > ^%RplcLstCnt% wrapup
      ^!SetCode %rplcitem%=^$UseTokens(^$GetValue("ReplaceDialog:ReplaceList_^%count%")$)$
      ^!SetCode %rplclist%=^%rplclist%~OR~^%rplcitem%
      ^!Goto rplcliscnt
      :wrapup
      ;from replace clip in Clip Assistant, amended to insert default values in wizards
      ;THERE IS A PROBLEM when the values retrieved from the ini file have their own
      ;vertical bars in them!
      ^!Set %srchlist%=^$StrReplace("|";"!OR!";"^%srchlist%";No;No)$
      ^!Set %srchlist%=^$StrReplace("~OR~";"|";"^%srchlist%";No;No)$
      ;^!Set %srchlist%=^$StrReplace("\!OR!";"^%CARET%^%CARET%%VBAR%";"^%srchlist%";No;No)$
      ^!Set %srchlist%=^$StrReplace("!OR!";"^%CARET%^%CARET%%VBAR%";"^%srchlist%";No;No)$
      ^!Set %rplclist%=^$StrReplace("|";"!OR!";"^%rplclist%";No;No)$
      ^!Set %rplclist%=^$StrReplace("~OR~";"|";"^%rplclist%";No;No)$
      ;^!Set %rplclist%=^$StrReplace("\!OR!";"^CARET%^%CARET%%VBAR%";"^%rplclist%";No;No)$
      ^!Set %rplclist%=^$StrReplace("!OR!";"^CARET%^%CARET%%VBAR%";"^%rplclist%";No;No)$
      ^!Set %Name%=Replace
      ^!Set %Param%="^?{Find what (use tokens for tabs/paragraphs)=^%srchlist%}" >> "^?{Replace with (use tokens for tabs/paragraphs)=^%rplclist%}" ^?{(T=C)Replace all==_Yes^=A|No^=}^?{(T=C)Whole words==_Yes^=C|No^=T|Automatic^=}^?{(T=C)Ignore case==_Yes^=I|No^=}^?{(T=C)Search backwards==Yes^=B|_No^=}^?{(T=C)All documents==Yes^=G|_No^=}^?{(T=C)Whole document==_Yes^=W|No^=}^?{(T=C)Only in selection==Yes^=H|_No^=}^?{(T=C)Regular Expression==Yes^=R|_No^=}^?{(T=C)Display messages==Yes^=|_No^=S}
      ^!Set %C%=^$DecToChar(127)$^$DecToChar(22)$
      ^!Set %Param%=^$StrReplace("^^P";"^%C%P";"^%Param%";False;False)$
      ^!Set %Param%=^$StrReplace("^^T";"^%C%T";"^%Param%";False;False)$
      ^!Set %Param%=^$StrReplace("^%C%";"^%CARET%^%CARET%";"^%Param%";False;False)$
      ^!InsertText ^
      ^!InsertText !^%Name% ^%Param%^P
      ^!GoTo Exit
      ;end of clip
    • hpaulissen
      Hi Alan and Sheri, This afternoon at work I saw your previous posts on the S&R clip. Nice job. I started off something similar myself, just for fun, and I
      Message 2 of 10 , Jul 3, 2002
      • 0 Attachment
        Hi Alan and Sheri,

        This afternoon at work I saw your previous posts on the S&R clip.
        Nice job. I started off something similar myself, just for fun, and I
        didn't have your examples with me, so here is another approach. I
        didn't test your latest contributions (about to go to bed), but maybe
        you can find something useful in the following. I use UseTokens in
        the wizards, and that works. I'm only having problems with { and }
        appearing in the wizards (I guess if these appear in the ini, they
        are interpreted as some clipcode).

        Although I liked Alan's approach to show all values at once (no
        scrolling), I opted for scrollable lists with the possibility to
        enter a new value in Search / Replace.


        :Start
        ^!ProgIniSave
        ^!Set %ChangedKey%=0
        ^!Set %Count%=1
        ^!Set %Key%=Search
        ^!Set %^%Key%List%=""
        ^!Set %Text%=""
        :LISTS
        ^!Set %Value%=^$GetValue(ReplaceDialog:^%Key%List_^%Count%)$
        ^!IfTrue ^$IsEMPTY(^%Value%)$ CHANGEKEY
        ^!Append %^%Key%List%=^%Value%|
        ^!INC %Count%
        ^!GoTO LISTS
        :CHANGEKEY
        ^!IfTrue ^%ChangedKey% END
        ^!Set %ChangedKey%=1
        ^!Set %Count%=1
        ^!Set %Key%=Replace
        ^!Set %^%Key%List%=""
        ^!GoTO LISTS
        :END
        ^!Append %Text%=^!Replace "^?{Search=^$UseTokens(^%SearchList%)$}"
        >> "^?{Replace=^$UseTokens(^%ReplaceList%)$}"
        ^!Append %Text%= ^?{Regular Expression?==Regular
        Expression^=R|_No^=|Search Backwards (not for RegEx)^=B}
        ^!Append %Text%=^?{Search Where?==All open documents^=G|_Whole
        Document^=W|Only Within Hihglighted Selection^=H}
        ^!Append %Text%=^?{Silent Search?==_Yes^=S|No^=}
        ^!Append %Text%=^?{Replace All Occurences?==_Yes^=A|No^=}
        ^!InsertText ^%Text%


        Hugo
      • hsavage
        ... Hello Alan, Sheri, Hugo and any other interested parties, Several have taken a try at some variation of this replace dialog clips. I thought I might take
        Message 3 of 10 , Jul 6, 2002
        • 0 Attachment
          > Alan C wrote:
          >
          > (*New* much better replace dialog clip enclosed below too)
          > ---
          > I had said
          >
          > I need help with check box wizard.
          >
          > H="replace dialog 2clips"
          > ^!ClearVariables
          > ^!Set %SrchLstCnt%=^$GetValue("ReplaceDialog:SearchListCount")$
          >
          >
          > Regards. Alan.


          Hello Alan, Sheri, Hugo and any other interested parties,

          Several have taken a try at some variation of this replace dialog
          clips. I thought I might take a shot. This clip handles the special
          characters, |, ^p, ^t, etcetera.

          This clip might be modified to fit into the cliphelp library but that
          wasn't my goal. I'm trying for versatility in writing a clip ^!Replace
          command string as was originally attempted.

          This clip works without a combo box except for selecting the
          find-replace options. It gives you full access to all the s/r strings
          stored in NotePro.ini and you can gather s/r strings from other open
          files if you need to.

          Run this clip, it first displays all s/r strings from the .ini in a new
          blank doc. You can choose your search data from either the search or
          replace side, same for the replace data. You can type new data into the
          doc or you can switch to other open files for search-replace data also.

          The clip does require slightly more user involvement than just mouse clicks.

          After selecting the Search data the user presses the CtrlKey, then user
          selects Replace data amd presses the ShiftKey. At this point you get a
          combo checkbox for selecting s/r options, 5 options are preselected.

          I'm adding the clip on in 2 forms, first is a straight clip with a blank
          line under it for easy identification in case of email wrapping.

          Second form is formatted for sending thru email and the small clip at
          it's top is for de-formatting the large clip. Just follow the
          instructions in the small clip comments.


          hrs

          ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
          regular clip, hope it isn't wrapped too much.


          H="SEARCH/REPLACE DIALOGS"
          ^!ClearVariables
          ^!Menu File/New
          ^!SetWordWrap 0
          ^!Set %di%=^$GetDocIndex(^##)$
          ^!Set %SearchListCount%=^$GetValue("ReplaceDialog:SearchListCount")$
          ^!Set %ReplaceListCount%=^$GetValue("ReplaceDialog:ReplaceListCount")$
          ;
          ^!InsertText >>>-SEARCH DATA, ^%SearchListCount% ITEMS.^%nl%
          ^!Set %count%=0
          :SEARCHLISTCOUNT
          ^!Inc %count%
          ^!InsertCode
          ^$UseTokens(^$GetValue("ReplaceDialog:SearchList_^%count%")$)$^%nl%
          ;
          ^!If ^%count% = ^%SearchListCount% NEXT ELSE SearchListCount
          ^!InsertText ^p>>>-REPLACE DATA, ^%ReplaceListCount% ITEMS.^%nl%
          ^!Set %count%=0
          :REPLACELISTCOUNT
          ^!Inc %count%
          ^!InsertCode
          ^$UseTokens(^$GetValue("ReplaceDialog:ReplaceList_^%count%")$)$^%nl%
          ;
          ^!If ^%count% = ^%ReplaceListCount% NEXT ELSE ReplaceListCount
          :SET_SEARCH
          ^!SetHintInfo Select SEARCH data and Press CtrlKey
          ;^!StatusShow Select SEARCH data and Press CtrlKey
          ^!IfFalse ^$IsCtrlKeyDown$ SET_SEARCH
          ^!Set %search%=^$GetSelection$
          ^!If ^$StrCopyRight(^%search%;2)$ = ^%nl% ^!Set
          %search%=^$StrDeleteRight(^$GetSelection$;2)$
          ;
          ^!Jump Select_Start
          :SET_REPLACE
          ^!SetHintInfo Select REPLACE data and Press ShiftKey
          ;^!StatusShow Select REPLACE data and Press ShiftKey
          ^!IfFalse ^$IsShiftKeyDown$ SET_REPLACE
          ^!Set %replace%=^$GetSelection$
          ^!If ^$StrCopyRight(^%replace%;2)$ = ^%nl% ^!Set
          %replace%=^$StrDeleteRight(^$GetSelection$;2)$
          ;
          ^!Jump Select_Start
          ^!SetDocIndex ^%di%
          :SET_PARAMETERS
          ^!SetListDelimiter ;
          ^!Set %Params%=^?{(T=A;H=11)REPLACE DATA;==_Within Words^=T|Whole
          words^=C|_Ignore case^=I|Search backwards^=B|ALL open
          documents^=G|_Whole document^=W|Within selection^=H|Regular
          Expression^=R|_Silent search^=S|_ALL occurrences^=A}
          ;
          ^!Set %params%=^$StrReplace(";";^%empty%;^%params%;0;0)$
          ^!SetClipboard ^!Replace "^%search%" >> "^%replace%" ^%params%^%nl%
          ^!Close DISCARD

          ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
          email formatted clips


          H="ECW_RESTORE"
          ; ***IMPORTANT***
          ; SIMPLEST METHOD
          ;
          ; COPY BOTH THESE
          ; CLIPS TO A BLANK DOC.
          ;
          ; CUT FIRST CLIP TO THE CLIPBOARD,
          ; ADD/PASTE INTO ANY CLIPBOOK!
          ;
          ; RUN THIS CLIP ON THE REMAINING
          ; TEXT TO DE-FORMAT!
          ;
          ; THEN PASTE EXPANDED CLIP INTO CLIPBOOK
          ;
          ^!Clearvariables
          ^!SetWordwrap 0
          ^!SetScreenUpdate 0
          ^!ToolBar E-Mail UnQuote
          ^!Replace "^p" >> "" TIWSA
          ^!Replace "ºtº" >> "^t" TIWSA
          ^!Replace "ºsº" >> " " TIWSA
          ^!Replace "ºrº" >> "^p" TIWSA
          ^!Replace "ºcº" >> "^" TIWSA
          ^!Replace ºr~ >> "^p" tiwsa


          H="SEARCH/REPLACEºsºDIALOGS"ºrººcº!ClearVaria
          blesºrººcº!MenuºsºFile/Newºrººcº!SetWordWrapº
          sº0ºrººcº!Setºsº%di%=ºcº$GetDocIndex(ºcº##)$º
          rººcº!Setºsº%SearchListCount%=ºcº$GetValue("R
          eplaceDialog:SearchListCount")$ºrººcº!Setºsº%
          ReplaceListCount%=ºcº$GetValue("ReplaceDialog
          :ReplaceListCount")$ºrººcº!InsertTextºsº>>>-S
          EARCHºsºDATA,ºsººcº%SearchListCount%ºsºITEMS.
          ºcº%nl%ºrººcº!Setºsº%count%=0ºrº:SEARCHLISTCO
          UNTºrººcº!Incºsº%count%ºrººcº!InsertCodeºsººc
          º$UseTokens(ºcº$GetValue("ReplaceDialog:Searc
          hList_ºcº%count%")$)$ºcº%nl%ºrººcº!Ifºsººcº%c
          ount%ºsº=ºsººcº%SearchListCount%ºsºNEXTºsºELS
          EºsºSearchListCountºrººcº!InsertTextºsººcºp>>
          >-REPLACEºsºDATA,ºsººcº%ReplaceListCount%ºsºI
          TEMS.ºcº%nl%ºrººcº!Setºsº%count%=0ºrº:REPLACE
          LISTCOUNTºrººcº!Incºsº%count%ºrººcº!InsertCod
          eºsººcº$UseTokens(ºcº$GetValue("ReplaceDialog
          :ReplaceList_ºcº%count%")$)$ºcº%nl%ºrººcº!Ifº
          sººcº%count%ºsº=ºsººcº%ReplaceListCount%ºsºNE
          XTºsºELSEºsºReplaceListCountºrº:SET_SEARCHºrº
          ºcº!SetHintInfoºsºSelectºsºSEARCHºsºdataºsºan
          dºsºPressºsºCtrlKeyºrº;ºcº!StatusShowºsºSelec
          tºsºSEARCHºsºdataºsºandºsºPressºsºCtrlKeyºrºº
          cº!IfFalseºsººcº$IsCtrlKeyDown$ºsºSET_SEARCHº
          rººcº!Setºsº%search%=ºcº$GetSelection$ºrººcº!
          Ifºsººcº$StrCopyRight(ºcº%search%;2)$ºsº=ºsºº
          cº%nl%ºsººcº!Setºsº%search%=ºcº$StrDeleteRigh
          t(ºcº$GetSelection$;2)$ºrººcº!JumpºsºSelect_S
          tartºrº:SET_REPLACEºrººcº!SetHintInfoºsºSelec
          tºsºREPLACEºsºdataºsºandºsºPressºsºShiftKeyºr
          º;ºcº!StatusShowºsºSelectºsºREPLACEºsºdataºsº
          andºsºPressºsºShiftKeyºrººcº!IfFalseºsººcº$Is
          ShiftKeyDown$ºsºSET_REPLACEºrººcº!Setºsº%repl
          ace%=ºcº$GetSelection$ºrººcº!Ifºsººcº$StrCopy
          Right(ºcº%replace%;2)$ºsº=ºsººcº%nl%ºsººcº!Se
          tºsº%replace%=ºcº$StrDeleteRight(ºcº$GetSelec
          tion$;2)$ºrººcº!JumpºsºSelect_Startºrººcº!Set
          DocIndexºsººcº%di%ºrº:SET_PARAMETERSºrººcº!Se
          tListDelimiterºsº;ºrººcº!Setºsº%Params%=ºcº?{
          (T=A;H=11)REPLACEºsºDATA;==_WithinºsºWordsºcº
          =T|Wholeºsºwordsºcº=C|_Ignoreºsºcaseºcº=I|Sea
          rchºsºbackwardsºcº=B|ALLºsºopenºsºdocumentsºc
          º=G|_Wholeºsºdocumentºcº=W|Withinºsºselection
          ºcº=H|RegularºsºExpressionºcº=R|_Silentºsºsea
          rchºcº=S|_ALLºsºoccurrencesºcº=A}ºrººcº!Setºsº
          %params%=ºcº$StrReplace(";";ºcº%empty%;ºcº%pa
          rams%;0;0)$ºrººcº!SetClipboardºsººcº!Replaceº
          sº"ºcº%search%"ºsº>>ºsº"ºcº%replace%"ºsººcº%p
          arams%ºcº%nl%ºrººcº!CloseºsºDISCARDºrº
        • h.paulissen@facburfdcw.unimaas.nl
          Harvey, (& Sheri & Alan) Very nice clip, thank you... I ve changed a tiny bit in your clip, so that also after nothing is selected in Search and Replace (CTRL
          Message 4 of 10 , Jul 8, 2002
          • 0 Attachment
            Harvey, (& Sheri & Alan)

            Very nice clip, thank you... I've changed a tiny bit in your clip, so that
            also after nothing is selected in Search and Replace (CTRL and SHIFT) there
            will be no errormessage... (And you can now interrupt the clip with
            CTRL+ALT).

            I also inserted the proginisave to reflect the latest s+r patterns and a
            line underneath the "headers". A number is inserted in front of the
            ini-lines as well... (makes it a bit more readable, imho)

            Hugo

            ^!ClearVariables
            ^!ProgIniSave
            ^!Menu File/New
            ^!SetWordWrap 0
            ^!Set %di%=^$GetDocIndex(^##)$
            ^!Set %SearchListCount%=^$GetValue("ReplaceDialog:SearchListCount")$
            ^!Set %ReplaceListCount%=^$GetValue("ReplaceDialog:ReplaceListCount")$
            ^!InsertText >>>-SEARCH DATA, ^%SearchListCount%
            ITEMS.^%nl%---------------------------^%nl%
            ;
            ^!Set %count%=0
            :SEARCHLISTCOUNT
            ^!Inc %count%
            ^!InsertCode ^%Count%:
            ^$UseTokens(^$GetValue("ReplaceDialog:SearchList_^%count%")$)$^%nl%
            ^!If ^%count% = ^%SearchListCount% NEXT ELSE SearchListCount
            ^!InsertText ^p>>>-REPLACE DATA, ^%ReplaceListCount%
            ITEMS.^%nl%---------------------------^%nl%
            ;^!Set %count%=0
            :REPLACELISTCOUNT
            ^!Inc %count%
            ^!InsertCode ^%Count%:
            ^$UseTokens(^$GetValue("ReplaceDialog:ReplaceList_^%count%")$)$^%nl%
            ^!If ^%count% = ^%ReplaceListCount% NEXT ELSE ReplaceListCount
            ;^!GoTo END
            :SET_SEARCH
            ^!SetHintInfo Select SEARCH data and Press CtrlKey
            ^!IfFalse ^$IsCtrlKeyDown$ SET_SEARCH
            ^!Set %search%=...^$GetSelection$
            ^!If ^$StrCopyRight(^%search%;2)$ = ^%nl% ^!Set
            %search%=^$StrDeleteRight(^%search%;2)$
            ;
            ^!Jump Select_Start
            :SET_REPLACE
            ^!SetHintInfo Select REPLACE data and Press ShiftKey
            ;^!StatusShow Select REPLACE data and Press ShiftKey
            ^!IfFalse ^$IsShiftKeyDown$ SET_REPLACE
            ^!Set %replace%=...^$GetSelection$
            ^!If ^$StrCopyRight(^%replace%;2)$ = ^%nl% ^!Set
            %replace%=^$StrDeleteRight(^%replace%;2)$
            ;
            ^!Jump Select_Start
            ^!SetDocIndex ^%di%
            :SET_PARAMETERS
            ^!SetListDelimiter ;
            ^!Set %Params%=^?{(T=A;H=11)REPLACE DATA;==_Within Words^=T|Whole
            words^=C|_Ignore case^=I|Search backwards^=B|ALL open documents^=G|_Whole
            document^=W|Within selection^=H|Regular Expression^=R|_Silent search^=S|_ALL
            occurrences^=A}
            ;
            ^!Set %params%=^$StrReplace(";";^%empty%;^%params%;0;0)$
            ^!SetClipboard ^!Replace "^$strDeleteLeft(^%search%;3)$" >>
            "^$strDeleteLeft(^%replace%;3)$" ^%params%^%nl%
            ;
            ^!Close DISCARD


            >
            > This clip works without a combo box except for selecting the
            > find-replace options. It gives you full access to all the
            > s/r strings
            > stored in NotePro.ini and you can gather s/r strings from other open
            > files if you need to.
            >
            > Run this clip, it first displays all s/r strings from the
            > .ini in a new
            > blank doc. You can choose your search data from either the search or
            > replace side, same for the replace data. You can type new
            > data into the
            > doc or you can switch to other open files for search-replace
            > data also.
            >
            > The clip does require slightly more user involvement than
            > just mouse clicks.
            >
            > After selecting the Search data the user presses the CtrlKey,
            > then user
            > selects Replace data amd presses the ShiftKey. At this point
            > you get a
            > combo checkbox for selecting s/r options, 5 options are preselected.
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.