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

Fixed -> (not always) Working Replace clip!

Expand Messages
  • Sheri
    Hi guys, Even though the other approach is much more sensible, I gave myself a migraine and fixed the s/r selection through the wizard. I ve also modified my
    Message 1 of 1 , Jul 11, 2002
    • 0 Attachment
      Hi guys,

      Even though the other approach is much more sensible, I gave myself a migraine
      and fixed the s/r selection through the wizard. I've also modified my options
      wizard presentation so that part of it uses check boxes.

      It was only failing if any prior s/r text had unbalanced or non-matching curly
      braces. Now any such lines get presented with a "Bypass Wizard key" prefix and
      square bracket string substitutions while selecting from the wizard. But if such a
      line is selected for building the command, the actual ini value is used.

      I would appreciate if you wouldn't mind seeing if you can break it. :}

      Regards,
      Sheri

      This clip can be viewed and copied without linebreaks at:

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


      H="Replace Command Builder"
      :Start
      ^!Set %Name%=Replace
      ^!Set %Param%=""
      ^!ProgIniSave
      ^!Set %ChangedKey%=0
      ^!Set %Count%=1
      ^!Set %Key%=Search
      ^!Set %SearchList%=""
      ^!Set %ReplaceList%=""
      :LISTS
      ^!Setcode %Value%="^$StrReplace("|";"¦";"^$UseTokens(^$GetValue("ReplaceDialog:^%Key%List_^%Count%")$)$";No;No)$"
      ^!If ^$StrCount("{";"^%Value%";False;False)$ = ^$StrCount("}";"^%Value%";False;False)$ Next Else WINGIT
      ^!If ^$StrCount("{";"^%Value%";False;False)$ = 0 DOLIST Else INITBRACES
      :WINGIT
      ^!Set %Override^%Key%List_^%Count%%=^%Value%
      ^!Set %Value%=^$StrReplace("{";"[";"^$UseTokens(^%Value%)$;FALSE;FALSE)$
      ^!Set %Value%=^$StrReplace("}";"]";"^$UseTokens(^%Value%)$;FALSE;FALSE)$
      ^!Set %Value%="Bypass Wizard ^%Key%List_^%Count% ^$UseTokens(^%Value%)$"
      ^!Goto DOLIST
      :INITBRACES
      ^!Set %Done%=0
      ^!Set %Iterate%=^$StrCount("{";"^%Value%";False;False)$
      ^!SetListDelimiter }
      ^!SetArray %TestBraces%=^$StrCopyLeft("^%Value%";^$StrPosRight("}";"^%Value%";False)$)$
      :TESTBRACES
      ^!If ^%Done%=^%Iterate% DOLIST
      ^!Inc %Done%
      ^!If ^$StrPos("{";"^%TestBraces^%Done%%";False)$=0 WINGIT
      ^!Goto TESTBRACES
      :DOLIST
      ^!IfTrue ^$IsEMPTY(^%Value%)$ CHANGEKEY
      ^!Append %^%Key%List%=^%Value%|
      ^!INC %Count%
      ^!GoTO LISTS
      :CHANGEKEY
      ^!IfTrue ^%ChangedKey% DOPARAM
      ^!Set %ChangedKey%=1
      ^!Set %Count%=1
      ^!Set %Key%=Replace
      ^!Set %^%Key%List%=""
      ^!GoTO LISTS
      :DOPARAM
      ^!SetListDelimiter ¶
      ^!Set %Param%="^?{Find what (use tokens for tabs/paragraphs)=^%SearchList%}" >> "^?{Replace with (use tokens for tabs/paragraphs)=^%ReplaceList%}" ^?{(T=A;H=11)Options==All occurrences^=A|_Ignore case^=I|Regular Expression^=R|_Supress Messages^=S}^?{(T=C)Word Boundaries=_Automatic^=|Within Words^=T|Whole words^=C}^?{(T=C)Direction==_Down from Cursor Location^=|Up from Cursor Location^=B|Down from Top of Document^=W}^?{Scope Modifications==_None^=""|Replace only in Highlighted selection^=H|Replace as specified in all open documents (Global)^=G}
      ^!IfCancel EXIT
      ^!Set %Param%=^$StrReplace("¶";"";"^%Param%";False;False)$
      ^!Set %Param%=^$StrReplace("¦";"^%VBAR%";"^%Param%";False;False)$
      ^!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)$
      ^!If ^$StrCount("Bypass Wizard";^%Param%;FALSE;FALSE)$=0 NORMAL ELSE ABNORMAL
      :NORMAL
      ^!InsertText ^!^%Name% ^%Param%^P
      ^!GOTO EXIT
      :ABNORMAL
      ^!Set %Options%=^$StrCopyRight(^%Param%;^$Calc(^$StrSize(^%Param%)$-^$Calc(^$StrPosRight(" ";^%Param%;FALSE)$)$)$)$
      ^!Set %Searchtext%=^$StrCopyLeft(^%Param%;^$Calc(^$StrPos("" >>";^%Param%;FALSE)$)$)$
      ^!Set %Replacetext%=^$StrCopy(^%Param%;^$Calc(^$StrPosRight("" >> ";^%Param%;FALSE)$+6)$;^$Calc(^$StrSize(^%Param%)$-^$Calc(^$StrPosRight("" >> ";^%Param%;FALSE)$+6)$-^$Calc(^$StrSize(^%Param%)$-^$Calc(^$StrPosRight(" ";^%Param%;FALSE)$)$)$-1)$)$
      ^!IF ^$StrCount("Bypass Wizard";^%Param%;FALSE;FALSE)$=1 CHOOSEWHICH
      ^!IF ^$StrCount("Bypass Wizard";^%Param%;FALSE;FALSE)$=2 FIXBOTH
      ^!IF ^$StrCount("Bypass Wizard";^%Param%;FALSE;FALSE)$>2 CLIPFAILURE
      :CHOOSEWHICH
      ^!IF ^$StrCount("Bypass Wizard Search";^%Param%;FALSE;FALSE)$=1 FIXSEARCH
      ^!IF ^$StrCount("Bypass Wizard Replace";^%Param%;FALSE;FALSE)$=1 FIXREPLACE
      ^!Goto CLIPFAILURE
      :FIXSEARCH
      ^!Set %endpos%=^$StrPosMid(" ";^%Searchtext%;15;False)$
      ^!If ^%endpos%=0 ^!Set %endpos%=^$StrSize(^%SearchText%)$
      ^!Set %ORIndex%=^$StrCopy(^%SearchText%;15;^$Calc(^%endpos%-15)$)$
      ^!Set %SearchText%=^%Override^%ORIndex%%
      ^!Set %Param%="^%SearchText%" >> "^%ReplaceText%" ^%Options%
      ^!Goto NORMAL
      :FIXREPLACE
      ^!Set %endpos%=^$StrPosMid(" ";^%Replacetext%;15;False)$
      ^!If ^%endpos%=0 ^!Set %endpos%=^$StrSize(^%ReplaceText%)$
      ^!Set %ORIndex%=^$StrCopy(^%ReplaceText%;15;^$Calc(^%endpos%-15)$)$
      ^!Set %ReplaceText%=^%Override^%ORIndex%%
      ^!Set %Param%="^%SearchText%" >> "^%ReplaceText%" ^%Options%
      ^!Goto NORMAL
      :FIXBOTH
      ^!IF ^$StrCount("Bypass Wizard Search";^%Param%;FALSE;FALSE)$=1 Next Else CLIPFAILURE
      ^!IF ^$StrCount("Bypass Wizard Replace";^%Param%;FALSE;FALSE)$=1 Next Else CLIPFAILURE
      ^!Set %endpos%=^$StrPosMid(" ";^%Searchtext%;15;False)$
      ^!If ^%endpos%=0 ^!Set %endpos%=^$StrSize(^%SearchText%)$
      ^!Set %ORIndex%=^$StrCopy(^%SearchText%;15;^$Calc(^%endpos%-15)$)$
      ^!Set %SearchText%=^%Override^%ORIndex%%
      ^!Set %endpos%=^$StrPosMid(" ";^%Replacetext%;15;False)$
      ^!If ^%endpos%=0 ^!Set %endpos%=^$StrSize(^%ReplaceText%)$
      ^!Set %ORIndex%=^$StrCopy(^%ReplaceText%;15;^$Calc(^%endpos%-15)$)$
      ^!Set %ReplaceText%=^%Override^%ORIndex%%
      ^!Set %Param%="^%SearchText%" >> "^%ReplaceText%" ^%Options%
      ^!Goto NORMAL
      :CLIPFAILURE
      ^!Info ClipFailure - there may have been a problem building the command, please correct the Search and Replace texts manually
      ^!Goto NORMAL
      ^!Goto EXIT
      :EXIT
      ^!ClearVariables
      ;end of clip
    Your message has been successfully submitted and would be delivered to recipients shortly.