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

Re: [Clip] How to clear ^&

Expand Messages
  • Axel Berger
    ... Yes. Let me start with a preliminary. Let s have an autorun clip called
    Message 1 of 8 , Jun 14, 2012
      Ian NTnerd wrote:
      > Can you give more of your clip (trimmed down perhaps)
      > so we can see what you are doing.

      Yes. Let me start with a preliminary. Let's have an autorun clip called
      "<0a" and containing
      "^!InsertText something^P^&". You invoke it by typing "<0a ". With ^&
      that last space does nothing, without it you end up with
      <newline><space>. So I always use ^!Insert with ^&

      Now I already have a clip (first line is long) (LaTeX code):

      ^!Set %Ebene%=^?{Level=0}; %Kaptit%=^?{Titel=^%Kaptit%};
      %Kappag%=^?{Seite=};
      %Seiten%=^?{(T=L,H=7)Seitenzählung=keine|_arabic|roman|Roman|alph|Alph};
      %Vakat%=^?{(T=L,H=7)Vakatseite=ja|_nein}
      ^!Set %vPag%=^%Kappag%
      ^!IfFalse ^$IsNumber(^%vPag%)$ SKIP
      ^!Set %vPag%=^$Calc(^%vPag%;0)$
      ^!IfDiff "^%Vakat%" "ja" SKIP
      ^!InsertText \newpage ~^P^&
      ^!InsertText \newpage\pdfbookmark[^%Ebene%]{^%Kaptit%^&
      ^!IfSame "^%Seiten%" "keine" SKIP
      ^!InsertText ^%SPACE%^%vPag%^&
      ^!InsertText }{^%Kappag%}^P^&
      ^!IfSame "^%Seiten%" "keine" SKIP
      ^!InsertText \pagenumbering{^%Seiten%}\setcounter{page}{^%vPag%}^P^&

      This works fine. The following version works too when started through
      <ESC> with or without something selected.

      ^!Set %Zeile%=^%NL%; %Kaptit%=^%EMPTY%
      ^!If ^$GetSelSize$<1 nosel
      ^!Set %Kaptit%=^$GetSelection$
      ^!Set %Zeile%=""
      ^!Keyboard DELETE
      :nosel
      ^!Set %Ebene%=^?{Level=0}; %Kaptit%=^?{Titel=^%Kaptit%};
      %Kappag%=^?{Seite=};
      %Seiten%=^?{(T=L,H=7)Seitenzählung=keine|_arabic|roman|Roman|alph|Alph};
      %Vakat%=^?{(T=L,H=7)Vakatseite=ja|_nein}
      ^!Set %vPag%=^%Kappag%
      ^!IfFalse ^$IsNumber(^%vPag%)$ SKIP
      ^!Set %vPag%=^$Calc(^%vPag%;0)$
      ^!IfDiff "^%Vakat%" "ja" SKIP
      ^!InsertText \newpage ~^P
      ^!InsertText \newpage\pdfbookmark[^%Ebene%]{^%Kaptit%
      ^!IfSame "^%Seiten%" "keine" SKIP
      ^!InsertText ^%SPACE%^%vPag%
      ^!InsertText }{^%Kappag%}^P
      ^!IfSame "^%Seiten%" "keine" SKIP
      ^!InsertText \pagenumbering{^%Seiten%}\setcounter{page}{^%vPag%}^%Zeile%

      Started through autorun it will insert that spurious space, adding a ^&
      anywhere will cause other kinds of trouble whenever something was
      selected.

      A clip that should run through autorun as well as through <Esc> both
      with and without a selection is something I use quite often. It is easy
      whenever there is just one ^!Insert (there may be many ^!Set) and I can
      use ^& to lace the selection, if any. The problem only arises with
      several ^!Insert.

      Sorry, my examples could probably be shorter and clearer.

      Axel
    • Axel Berger
      ... Solved that one. Just add ^!Set %AR_KEY%=^%EMPTY% to the clip. But that s a very partial solution. I still want to place the cursor in the middle of an
      Message 2 of 8 , Jun 14, 2012
        Axel Berger wrote:
        > Started through autorun it will insert that spurious space,

        Solved that one. Just add

        ^!Set %AR_KEY%=^%EMPTY%

        to the clip. But that's a very partial solution. I still want to place
        the cursor in the middle of an ^!Insert sometimes. Then I need an empty
        ^& with nothing but its cursor positioning function.

        Axel
      • Art Kocsis
        ... That is strange. I have used this throughout my library but instead of ^P I used ^%nl% and have never seen an extra space following the ^%nl%. Do you see
        Message 3 of 8 , Jun 14, 2012
          At 6/14/2012 07:53 AM, Axel wrote:
          >Yes. Let me start with a preliminary. Let's have an autorun clip called
          >"<0a" and containing
          >"^!InsertText something^P^&". You invoke it by typing "<0a ". With ^&
          >that last space does nothing, without it you end up with
          ><newline><space>. So I always use ^!Insert with ^&

          That is strange.

          I have used this throughout my library but instead of ^P I used ^%nl%
          and have never seen an extra space following the ^%nl%.

          Do you see the same behavior using ^%nl%?

          Are you running NTS or NTP? Which version?

          Art
        • flo.gehrke
          ... In NT 7.0, you could use the new ^!DeleteSelection command. IMHO, ^& is nothing that could be cleared like a variable. NT sticks to the string that
          Message 4 of 8 , Jun 15, 2012
            --- In ntb-clips@yahoogroups.com, Axel Berger <Axel-Berger@...> wrote:

            > The very next things I want to do is delete the selection and
            > clear the ^&. The first can be done through ^!Keyboard DELETE,
            > although I'd like a better and more specific way, and the second
            > I don't know how to do at all.

            In NT 7.0, you could use the new '^!DeleteSelection' command.

            IMHO, '^&' is nothing that could be "cleared" like a variable. NT sticks to the string that has been selected when starting the clip. Neither removing that string nor executing '^!Select 0' can "clear" the '^&' token. If I'm not mistaken, it's "empty" only if you start another clip (no subclip!) without having selected anything.

            As Sheri once put it: '^&' is "a shorthand for preselected text (preselected prior to executing your clip)" (3.3.2007, #16164). Also: "The '^&' is not an argument pass-er, it is the argument pass-ed" (1.12.2008, #18759). Consequently, it's just a side effect that -- on certain conditions -- '^&' seems to be able to "position the cursor".

            > The label ^& fulfils two functions. It saves and inserts what
            > was selected before running the clip and it positions the cursor.

            '^&' also works as a parameter string without selecting anything. Example: If you run...

            ; Start clip
            ^!Clip Names Otto

            ; Subclip 'Names'
            ^!Info His name was ^&

            ...the name 'Otto' will be displayed in an info box without selecting any text.

            Regards,
            Flo


            P.S. BTW, where is Sheri? I strongly miss her expertise!
          • Axel Berger
            ... Pro, version 6.2. And the behaviour described is documented in the main help file: Note that if the Clip contains the cursor-positioning code ^&, the
            Message 5 of 8 , Jun 15, 2012
              Art Kocsis wrote:
              > Are you running NTS or NTP? Which version?

              Pro, version 6.2. And the behaviour described is documented in the main
              help file:
              "Note that if the Clip contains the cursor-positioning code ^&, the
              activating key is automatically discarded. You can also use the
              activating key in Clip code through the new predefined variable
              ^%AR_KEY%."

              Reversing that: no ^& means no discard of the last character typed. Have
              you tried my minimal example?

              Axel
            • Axel Berger
              ... That s bad. Whenever a wizard inserts a more or less complicated environment the cursor should be placed in some specific spot right in the middle and
              Message 6 of 8 , Jun 15, 2012
                "flo.gehrke" wrote:
                > Consequently, it's just a side effect that -- on certain
                > conditions -- '^&' seems to be able to "position the cursor".

                That's bad. Whenever a wizard inserts a more or less complicated
                environment the cursor should be placed in some specific spot right in
                the middle and whenever marking up an ASCII source selecting smething to
                run a clip on is often desirable. It can

                a) save an extra <Ctrl><C> and <Ctrl><V> inside the wizard and
                b) I can highlight one thing and paste another.

                In my link wizard I highlight the text that is to become the link and
                paste the destination.

                By the way:
                > In NT 7.0,

                Must get around to going over. Any known gotchas, stuff that won't work
                as before?

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