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

Re: [Clip] Re: Limit Reformatting to Copied Text WAS: Join Lines: Special marker for lists?

Expand Messages
  • Clueless in Seattle
    ... I think we may have gone too far and taken out too much. I d like to keep the clipboard business in the clip if possible and only remove the bits that
    Message 1 of 3 , Sep 5, 2001
    • 0 Attachment
      h.paulissen@... wrote:

      > ^$StrFormat(^$GetClipboard$;0;70;True)$
      >
      > This would do the trick; all replace commands are removed and you
      > don't need the variable to work with the content of the clipboard
      > anymore...

      I think we may have gone too far and taken out too much. I'd like to
      keep the clipboard business in the clip if possible and only remove
      the bits that inserted and removed the paragraph markers.

      Here's your original clip again:

      ^!Set
      %NewText%=^$StrReplace("*";"^P*";^$GetClipboard$;False;False)$
      ^!Set %NewText%=^$StrFormat(^%NewText%;0;70;True)$
      ^!Set %NewText%=^$StrReplace("^P*";"*";^%NewText%;False;False)$
      ^%NewText%

      What I'm trying to tease out of it is how you turn the contents of the
      clipboard into a string that you can then re-format. That's what your
      clip does doesn't it?

      So it would be helpful to me if I could see the clip without the
      commands that insert and remove the paragraph markers. So maybe a
      better way to tackle it would be to try to remove those steps myself.

      ^!Set %NewText%=(^$GetClipboard$;False;False)$
      ^!Set %NewText%=^$StrFormat(^%NewText%;0;70;True)$
      ^%NewText%

      How did I do?
    • Clueless in Seattle
      I stumbled on the ^!PasteSelect command quite by accident, but it looked like it might be just what I was looking for. I added it to the clip Jody wrote and
      Message 2 of 3 , Sep 5, 2001
      • 0 Attachment
        I stumbled on the ^!PasteSelect command quite by accident, but it
        looked like it might be just what I was looking for. I added it to
        the clip Jody wrote and now seem to have a working "Paste Text from
        WEB page" clip:

        ^!PasteSelect
        ^$StrFormat("^$GetSelection$";0;9999999;0)$
        ^!Save

        I've tried it and it reformats just the the text that is pasted --
        leaving the rest of the text in the file untouched -- so it seems to
        do just what I wanted it to.

        So now I guess it's time I sat down and studied that line of code that
        Jody gave me to see if I can figure out what each bit of it is doing:

        ^$StrFormat - Format the named string as follows

        "^$GetSelection$" - The string to format is the selected text

        0;9999999;0 - Left margin 0, No right margin, Don't Justify

        $ - But what is the dollar sign at the end? Does that mean that
        everything inside the parentheses is the name of the string?
      • h.paulissen@facburfdcw.unimaas.nl
        ... No, I don t think so, it only looks as if I removed too much... I ll explain below. I d like to ... the ... your ... You re on the way! But there are some
        Message 3 of 3 , Sep 5, 2001
        • 0 Attachment
          >> ^$StrFormat(^$GetClipboard$;0;70;True)$
          >>
          >> This would do the trick; all replace commands are removed and you
          >> don't need the variable to work with the content of the clipboard
          >> anymore...
          >
          >I think we may have gone too far and taken out too much.


          No, I don't think so, it only looks as if I removed too much... I'll
          explain below.


          I'd like to
          >keep the clipboard business in the clip if possible and only remove
          >the bits that inserted and removed the paragraph markers.
          >
          >Here's your original clip again:
          >
          > ^!Set
          >%NewText%=^$StrReplace("*";"^P*";^$GetClipboard$;False;False)$
          > ^!Set %NewText%=^$StrFormat(^%NewText%;0;70;True)$
          > ^!Set %NewText%=^$StrReplace("^P*";"*";^%NewText%;False;False)$
          > ^%NewText%
          >
          >What I'm trying to tease out of it is how you turn the contents of
          the
          >clipboard into a string that you can then re-format. That's what
          your
          >clip does doesn't it?
          >
          >So it would be helpful to me if I could see the clip without the
          >commands that insert and remove the paragraph markers. So maybe a
          >better way to tackle it would be to try to remove those steps myself.
          >
          > ^!Set %NewText%=(^$GetClipboard$;False;False)$
          > ^!Set %NewText%=^$StrFormat(^%NewText%;0;70;True)$
          > ^%NewText%
          >
          >How did I do?


          You're on the way! But there are some small errors in your version.

          Here are some notes why the one-liner (without the replace) basically
          is the same as yours.

          Beware of syntactical errors however. Some of the functions can be
          nested and particularly then(!) it is wise to check and recheck your
          code for errors. To answer your other post about the $ sign:

          Format required for...
          Setting a variable:
          type %VariableName% (surround the name with %)
          Retreiving the variable:
          type ^%VariableName% (precede %VariableName% with a caret ^)
          Using a function:
          ^$FunctionName$ (Name, surrounded by $ and preceded by ^)

          Better read help for detailed explanations! Clip Language -
          Introduction...

          Enough for this sidestep...


          My original clip in order of execution - generally you can see what
          the machine does by reading from right to left:

          Line 1:
          ^!Set %NewText%=^$StrReplace("*";"^P*";^$GetClipboard$;False;False)$

          1. ^$GetClipboard$ - gets the clipboard, it is placed inside the
          ^$StrReplace(...) function as the text where the Replace operations
          needed to be done

          2. ^$StrReplace(...)$
          this is the proper format that should go in ():
          ("SubStr";"ReplaceStr";"Str";CaseSensitive;WholeWord)$
          ...in this case it is
          * - text to search for
          ^P* - text to replace the searchstring with (^P = paragraph marker)
          ^$GetClipboard$ (see step 1) - string where the replace should
          take place
          False (not case sensitive)
          False (not WholeWord)

          3. Fill Variable NewText with the result of step 2


          Line 2:
          ^!Set %NewText%=^$StrFormat(^%NewText%;0;70;True)$

          4. ^$StrFormat(^%NewText%;0;70;True)$
          Formats the Variable of step 3 with a left margin of 0, a text
          width of 70, and True says: Justify the result...

          5. The Variable is reset... with the result of step 4


          Line 3:
          ^!Set %NewText%=^$StrReplace("^P*";"*";^%NewText%;False;False)$

          6. As line 1: with some minor changes in step 2:
          ^P* - text to search for
          * - text to replace the searchstring with
          ^%NewText% - string where the replace should take place, we now
          have to deal with NewText (Clipboard after step 1-5)

          7. The Variable is reset... with the result of step 6




          You wanted to remove the replace-parts...

          ^!Set %NewText%=(^$GetClipboard$;False;False)$

          should actually be :

          ^!Set %NewText%=^$GetClipboard$

          Then the rest is okay

          ^!Set %NewText%=^$GetClipboard$
          ^!Set %NewText%=^$StrFormat(^%NewText%;0;70;True)$
          ^%NewText%

          But because I saw no reason to create a variable anymore, I replaced
          the Variable NewText (the result of the function ^$GetClipboard$) in
          the StrFormat-part of the clip with the ^$GetClipboard$-function
          itself. So you don't have to Set/use the Variable at all.

          ^$StrFormat(^$GetClipboard$;0;70;True)$ essentially is the same as
          your three line-version with the variable. It's what you prefer...

          Regards,

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