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

Clip to Load Replace Dialog

Expand Messages
  • Sheri
    Hi, If you ve ever wanted to use a saved search interactively from the Replace Dialog this clip is for you. It transfers a Find or Replace command from a clip
    Message 1 of 6 , Sep 3, 2002
    • 0 Attachment
      Hi,

      If you've ever wanted to use a saved search interactively from the Replace
      Dialog this clip is for you.

      It transfers a Find or Replace command from a clip or other file into the
      Replace dialog. (Note that it will only work on a clip document if launched
      from the Clipbar).

      Place the cursor anywhere on a line containing a clip Find or Replace command,
      then launch this clip.

      This clip requires the latest release of 4.91 (which allows dialog options to
      be changed with "+" or "-" keystrokes) and also a small utility for
      turning off Capslock. The utility is available here:
      http://www.rjlsoftware.com/software/utility/capslock/default.shtml

      On my hardware, the ^!Keyboard commands are reliable only with the "^!Delay 1"
      commands included. YMMV.

      Keep in mind that variables should not be used in Search or Replace texts
      executed from the Replace Dialog. For convenience, if the Replace text consists of
      "^%Empty%" it is replaced with nothingness.

      Once the dialog is loaded, you are prompted to switch to the target document.
      You can and should do this without closing the Replace dialog.

      This clip can be viewed and copied without broken lines around here:

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

      Let me know if you find any problems, I've been using it awhile now so
      it should be pretty clean. I find it useful, so hopefully others will too.

      Enjoy,
      Sheri

      H="Load Replace Dialog"
      ;08/20/2002 by Sheri Pierce
      ;not compatible with Notetab versions less than 4.91.
      ;Capslock freeware http://www.rjlsoftware.com/software/utility/capslock/default.shtml
      ^!ShellWait Capslock off
      ^!Select Line
      ^!SetListDelimiter ¶ >> ¶
      ^!Set %SRTexts%=^$StrReplace(""";"¶";"^$GetSelection$";False;False)$
      ^!Set %SRTexts%=^$StrReplace("^%NL%";"";"^%SRTexts%";False;False)$
      ^!SetArray %SRTexts%=^%SRTexts%
      ^!IfMatch "\^!Replace .*" "^%SRTexts1%" Replace
      ^!IfMatch "\^!Find .*" "^%SRTexts1%" Find
      ^!Goto Error
      :Replace
      ^!Set %SRTexts1%=^$StrDeleteLeft("^%SRTexts1%";11)$
      ^!If ^$StrPos("¶ ";"^%SRTexts2%";False)$=0 Skip_2
      ^!Set %SRTexts3%=^$StrTrim(^$StrDeleteLeft("^%SRTexts2%";^$StrPosRight("¶ ";"^%SRTexts2";False)$)$)$
      ^!Set %SRTexts2%=^$StrCopyLeft("^%SRTexts2%";^$StrPosRight("¶ ";"^%SRTexts2";False)$)$
      ^!Set %SRTexts2%=^$StrDeleteRight("^%SRTexts2%";1)$
      ^!Set %SRTexts1%=^$StrReplace("¶";""";^%SRTexts1%;False;False)$
      ^!Set %SRTexts2%=^$StrReplace("¶";""";^%SRTexts2%;False;False)$
      ^!If ^%SRTexts2%="^%Caret%Empty%" Next Else Skip
      ^!ClearVariable %SRTexts2%
      ^!Goto Dialog
      :Find
      ^!Set %SRTexts3%=^$StrTrim(^$StrDeleteLeft("^%SRTexts1%";^$StrPosRight("¶ ";"^%SRTexts1";False)$)$)$
      ^!Set %SRTexts1%=^$StrTrim(^$StrCopyLeft("^%SRTexts1%";^$StrPosRight("¶ ";"^%SRTexts1";False)$)$)$
      ^!Set %SRTexts1%=^$StrDeleteLeft("^%SRTexts1%";8)$
      ^!Set %SRTexts1%=^$StrDeleteRight("^%SRTexts1%";1)$
      ^!Set %SRTexts1%=^$StrReplace("¶";""";^%SRTexts1%;False;False)$
      ^!Goto Dialog
      :Dialog
      ^!Menu Search/Replace
      ^!IfAppOpen "Find and Replace" Next Else Skip_-1
      ^!FocusApp "Find and Replace"
      ^!Keyboard #^%SRTexts1%#
      ^!Keyboard TAB
      ^!Keyboard #^%SRTexts2%#
      ^!Keyboard Alt+X
      ^!Delay 1
      ^!Keyboard #-#
      :WholeWords
      ^!If ^$StrPos("C";"^%SRTexts3%";False)$>0 Next Else Skip_5
      ^!Keyboard Alt+W
      ^!Delay 1
      ^!Keyboard #+#
      ^!Delay 1
      ^!Goto Case
      ^!Keyboard Alt+W
      ^!Delay 1
      ^!Keyboard #-#
      ^!Delay 1
      :Case
      ^!If ^$StrPos("I";"^%SRTexts3%";False)$>0 Next Else Skip_5
      ^!Keyboard Alt+C
      ^!Delay 1
      ^!Keyboard #-#
      ^!Delay 1
      ^!Goto Search
      ^!Keyboard Alt+C
      ^!Delay 1
      ^!Keyboard #+#
      ^!Delay 1
      :Search
      ^!If ^$StrPos("B";"^%SRTexts3%";False)$>0 Next Else Skip_5
      ^!Keyboard Alt+H
      ^!Delay 1
      ^!Keyboard UP UP Tab
      ^!Delay 1
      ^!Goto Reg
      ^!If ^$StrPos("W";"^%SRTexts3%";False)$>0 Next Else Skip_5
      ^!Keyboard Alt+H
      ^!Delay 1
      ^!Keyboard DOWN DOWN Tab
      ^!Delay 1
      ^!Goto Reg
      ^!Keyboard Alt+H
      ^!Delay 1
      ^!Keyboard DOWN DOWN UP TAB
      ^!Delay 1
      :Reg
      ^!If ^$StrPos("R";"^%SRTexts3%";False)$>0 Next Else Skip_5
      ^!Keyboard Alt+X
      ^!Delay 1
      ^!Keyboard #+#
      ^!Delay 1
      ^!Goto AllDocs
      ^!Keyboard Alt+X
      ^!Delay 1
      ^!Keyboard #-#
      ^!Delay 1
      :AllDocs
      ^!If ^$StrPos("G";"^%SRTexts3%";False)$>0 Next Else Skip_5
      ^!Keyboard Alt+M
      ^!Delay 1
      ^!Keyboard #+#
      ^!Delay 1
      ^!Goto End
      ^!Keyboard Alt+M
      ^!Delay 1
      ^!Keyboard #-#
      ^!Delay 1
      ^!Goto End
      :Error
      ^!Prompt No Find or Replace command found in the line text.
      :End
      ^!Prompt Adjust Replace Dialog options if desired, then^%nl%Switch to target document, then^%nl%Position the cursor and "Find Next" or "Replace All" as desired.^%nl%(Press OK when you understand the instructions.)
      ^!ClearVariable %SRTexts%
      ;end clip
    • Alan C.
      Hi Sheri ... To say the least, your clip worked *very* nicely. But I m unsure if or how the saving/storage of any of the values that I (get plugged in) and
      Message 2 of 6 , Sep 3, 2002
      • 0 Attachment
        Hi Sheri

        >Let me know if you find any problems,

        To say the least, your clip worked *very* nicely.

        But I'm unsure if or how the saving/storage of any of the values that I (get plugged in) and run. Accumulate them in a clip (as opposed to Ntab main) ini or etc.?

        But I do not already have a supply of ^!find nor ^!replace built up with which to draw from.

        So I myself might add, in addition to what U already have, a couple more

        ^!IfMatch "R .*" "^%SRTexts1%" Replace
        ^!IfMatch "F .*" "^%SRTexts1%" Find

        So that, prior to run your clip, (as option) I could type into an empty doc

        R the >> theNORTH

        or

        F matchitdotcomruralonlynocity4thiskid

        --
        Not a problem I don't suppose. Nonetheless, I noticed it somehow place/put what (I think?) are non traditional entries into Ntab ini (S/L # 3 & # 4)

        [ReplaceDialog]
        SearchListCount=4
        SearchList_1="the "
        SearchList_2="the"
        SearchList_3="^!Replace "the" >> "theFEET\n\n" AISWR"
        SearchList_4="^!Replace "the" >> "theSOUTH" IWSA"
        ReplaceListCount=3
        ReplaceList_1="the SOUTH"
        ReplaceList_2="theFEET\n\n"
        ReplaceList_3="theSOUTH"

        What happens if the capslock is on? So far I didn't have it on nor did I yet get the app that turns it off.

        --
        Alan.
      • Jody
        Hi Sheri, ... We ll just have to call you, Go to town Sheri! :) I wish I had the time to write more scripts like I use to when I was a script writ n fool. ;)
        Message 3 of 6 , Sep 4, 2002
        • 0 Attachment
          Hi Sheri,

          >If you've ever wanted to use a saved search interactively from
          >the Replace Dialog this clip is for you.

          We'll just have to call you,"Go to town Sheri!" :) I wish I had
          the time to write more scripts like I use to when I was a script
          writ'n fool. ;) I do get a chance every now and then. Nice
          Clip. Perhaps you would like to post it over to the ntb-scripts
          list for its archives, or upload it as a file. (I did not check
          that setting when I made the list, <g>, so...)

          Happy Script'n!
          Jody Adair

          UnSubscribe, Options
          mailto:ntb-Scripts-UnSubscribe@yahoogroups.com
          http://groups.yahoo.com/group/ntb-clipclass

          The NoteTabbers Assistant Page
          http://www.notetab.net
        • silvermoonwoman2001
          Hi Alan, FWIW, I use my previously posted clip at message 8819 to capture ^!Find and ^!Replace commands I might want to reuse.
          Message 4 of 6 , Sep 4, 2002
          • 0 Attachment
            Hi Alan,

            FWIW, I use my previously posted clip at message 8819 to
            capture ^!Find and ^!Replace commands I might want to reuse.

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

            Many of them go into regular clips as part of a bigger
            purpose than just the finding or replacing. But I've also
            been saving a variety of Find/Replace commands into one
            "clip" where I now go for source commands to load into the
            dialog. I wouldn't want each of these commands in its own
            named clip.

            I also use it to load in peoples' posted find/replace
            commands that are part of larger clips, especially to help
            troubleshoot regular expressions.

            I've only recently added the parameter check box editing. If
            nothing else, it is nice not to have to click "Regular
            Expression" on or off.

            --- In ntb-clips@y..., "Alan C." <acumming@c...> wrote:
            > So I myself might add, in addition to what U already have, a
            > couple more
            >
            > ^!IfMatch "R .*" "^%SRTexts1%" Replace
            > ^!IfMatch "F .*" "^%SRTexts1%" Find
            >
            > So that, prior to run your clip, (as option) I could type
            > into an empty doc
            >
            > R the >> theNORTH
            >
            > or
            >
            > F matchitdotcomruralonlynocity4thiskid
            >

            Feel free to modify it any way you like. It would currently
            have problems without quotes around the texts, and it lops
            off a fixed number of charcters from the left side of the
            line to get rid of the command space quote.

            Also after posting I realized that I never fixed the
            processing of a ^!Find command with no option parameters. So
            you will find that

            ^!Find "It"

            doesn't load properly, but

            ^!Find "It" I

            does.

            (Replace commands work ok even without option parameters)

            > Not a problem I don't suppose. Nonetheless, I noticed it
            > somehow place/put what (I think?) are non traditional
            > entries into Ntab ini (S/L # 3 & # 4)
            >
            > [ReplaceDialog]
            > SearchListCount=4
            > SearchList_1="the "
            > SearchList_2="the"
            > SearchList_3="^!Replace "the" >> "theFEET\n\n" AISWR"
            > SearchList_4="^!Replace "the" >> "theSOUTH" IWSA"
            > ReplaceListCount=3
            > ReplaceList_1="the SOUTH"
            > ReplaceList_2="theFEET\n\n"
            > ReplaceList_3="theSOUTH"
            >

            Not sure what you're saying here?

            I did just discover that my prompt to switch documents comes
            up even when a line is rejected from processing (its not
            designed to locate the Replace command in your SearchList_3
            line above).

            I guess it wasn't quite as clean as I hoped.

            I'll fix this and the above Find issue and repost later.

            > What happens if the capslock is on? So far I didn't have it
            > on nor did I yet get the app that turns it off.
            >
            If capslock is on, your search text will be in opposite
            case. This would cause unintended results for most regular
            expressions (e.g., \w is not the same as \W, etc.), and also
            for any command using case sensitivity, (i.e., no "I" option
            parameter.)

            Regards,
            Sheri
          • silvermoonwoman2001
            Hi Jody, I never would have gotten into clipwriting without your able assistance - I know what clip writ n fool you ve been Take care, Sheri
            Message 5 of 6 , Sep 4, 2002
            • 0 Attachment
              Hi Jody,

              I never would have gotten into clipwriting without your able
              assistance - I know what clip writ'n fool you've been <g>

              Take care,
              Sheri
            • silvermoonwoman2001
              ... Huh, I see that now, it seems to come from use of ^!IfMatch command. Not exactly a use of dialog box, yet tampering with its value list. Not as serious to
              Message 6 of 6 , Sep 4, 2002
              • 0 Attachment
                --- In ntb-clips@y..., "Alan C." <acumming@c...> wrote:
                > Not a problem I don't suppose. Nonetheless, I noticed it somehow
                > place/put what (I think?) are non traditional entries into Ntab ini
                > (S/L # 3 & # 4)
                >
                > [ReplaceDialog]
                > SearchListCount=4
                > SearchList_1="the "
                > SearchList_2="the"
                > SearchList_3="^!Replace "the" >> "theFEET\n\n" AISWR"
                > SearchList_4="^!Replace "the" >> "theSOUTH" IWSA"
                > ReplaceListCount=3
                > ReplaceList_1="the SOUTH"
                > ReplaceList_2="theFEET\n\n"
                > ReplaceList_3="theSOUTH"

                Huh, I see that now, it seems to come from use of ^!IfMatch command.
                Not exactly a use of dialog box, yet tampering with its value list.
                Not as serious to me as the non-saving of null replace text <G>
                although that hasn't caused me much of a problem since you pointed
                out the possibility of finagling an "^%Empty%" into the value list
                (that was you wasn't it?)

                Regards,
                Sheri (Looking forward to version 5)
              Your message has been successfully submitted and would be delivered to recipients shortly.