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

Assigning replacement Text to a Variable

Expand Messages
  • bruce_marriott
    Sorry this is a newbie question I have highlighted a few words of text and in the clip I want to do the equivalent of: ^!MENU Modify/Text Case/Lower case ^!Set
    Message 1 of 7 , Oct 2, 2010
      Sorry this is a newbie question

      I have highlighted a few words of text and in the clip I want to do the equivalent of:
      ^!MENU Modify/Text Case/Lower case
      ^!Set %new%=^!Replace " " >> "%20" HAS

      Ie I want %new% to contain the highlighted text where the spaces have been converted to the text %20 and its all been made lc.

      This seems such a simple thing to want to do but I can't find the answer.
    • Axel Berger
      ... If you were to tell us what it is you want finally to achieve by this, we d probably be able to suggest a better way, but this does exactly what you
      Message 2 of 7 , Oct 2, 2010
        bruce_marriott wrote:
        > Ie I want %new% to contain the highlighted text where ...

        If you were to tell us what it is you want finally to achieve by this,
        we'd probably be able to suggest a better way, but this does exactly
        what you requested:

        ^!Set %new%=^$GetSelection$
        ^!Set %new%=^$StrLower("^%new%")$
        ^!Set %new%=^$StrReplace(" ";"%20";"^%new%";False;False)$
        ^!Continue ^%new%

        N.B: It would b easy to contract all that into a single line, but I
        prefer simpleness and easy legibility in my clips when having to come
        back to them months later.

        Axel
      • loro
        ... I saw you already have a regex clip, here s a couple of other ways. ^!Set %new%=^$FileToUrl( ^$StrLower( ^$GetSelection$ )$ )$ The above will also turn any
        Message 3 of 7 , Oct 2, 2010
          bruce_marriott wrote:
          >I have highlighted a few words of text and in the clip I want to do
          >the equivalent of:
          >^!MENU Modify/Text Case/Lower case
          >^!Set %new%=^!Replace " " >> "%20" HAS
          >
          >Ie I want %new% to contain the highlighted text where the spaces
          >have been converted to the text %20 and its all been made lc.

          I saw you already have a regex clip, here's a couple of other ways.

          ^!Set %new%=^$FileToUrl("^$StrLower("^$GetSelection$")$")$

          The above will also turn any backslashes to forward slashes, which
          may or may not be what you want, but the below will do only what you asked for.

          ^!Set %new%=^$StrReplace("
          ";"%20";"^$StrLower("^$GetSelection$")$";false;false)$

          You can look these functions up in Help.
          ^$GetSelection$
          ^$FileToUrl()$
          ^$StrLower()$
          ^$StrReplace()$

          Lotta
        • loro
          Hi again Bruce! :-) Forgot to warn you that both clips are one-liners. Email may break them in two. Lotta
          Message 4 of 7 , Oct 2, 2010
            Hi again Bruce! :-)

            Forgot to warn you that both clips are one-liners. Email may break them in two.

            Lotta
          • Axel Berger
            ... Lotta, it seems to me you mixed up Jeff s question in the off-topic list with Bruce s, unless there s something important I overlooked. Axel
            Message 5 of 7 , Oct 2, 2010
              loro wrote:
              > ^$FileToUrl()$

              Lotta,
              it seems to me you mixed up Jeff's question in the off-topic list with
              Bruce's, unless there's something important I overlooked.

              Axel
            • loro
              ... Nuh. Bruce wanted spaces URL encoded and that s what ^$FileToUrl()$ does - and then some. I suspect the strings really are URLs and maybe getting other
              Message 6 of 7 , Oct 3, 2010
                Axel Berger wrote:
                >loro wrote:
                > > ^$FileToUrl()$
                >
                >it seems to me you mixed up Jeff's question in the off-topic list with
                >Bruce's, unless there's something important I overlooked.

                Nuh. Bruce wanted spaces URL encoded and that's what ^$FileToUrl()$
                does - and then some. I suspect the strings really are URLs and maybe
                getting other fishy characters URL encoded comes in handy. My guess
                may be wrong of course.

                Lotta
              • Axel Berger
                ... Sounds reasonable. I repeat my earlier question: Bruce, if you were to tell us what it is you want that variable for, we d probably be able to give better
                Message 7 of 7 , Oct 3, 2010
                  loro wrote:
                  > I suspect the strings really are URLs

                  Sounds reasonable. I repeat my earlier question:
                  Bruce, if you were to tell us what it is you want that variable for,
                  we'd probably be able to give better advice. I have answered strictly
                  what you asked but prossibly not what you really meant.

                  Axel
                Your message has been successfully submitted and would be delivered to recipients shortly.