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

Re: [Clip] Re: Block Sorting

Expand Messages
  • Ray Shapp
    Hi Eb and Don,
    Message 1 of 13 , Mar 2 6:39 PM
    • 0 Attachment
      Hi Eb and Don,

      <<Right that would do it -- and you don't need the line breaks anyway --
      > that is what wordwrap is for.>>
      >

      Problem solved! The join/sort/split works perfectly. Done entirely within
      NoteTab, and no clip required.

      Thanks to all who responded - Axel, Don, Eb, Sheri. (Did you notice that you
      folks replied in alphabetical order?)

      Ray Shapp


      On Wed, Mar 2, 2011 at 7:51 PM, Don <don@...> wrote:

      >
      >
      > Right that would do it -- and you don't need the line breaks anyway --
      > that is what wordwrap is for.
      >
      >
      > > <<a quick an durty way might be to temporarily join each table row into a
      > >> single line (unwrapped), sort the lines >>
      >
      > > Both are good ideas. I'm experimenting with them both.
      >
      >


      [Non-text portions of this message have been removed]
    • Eb
      Yes, Microsoft s latest invention, the cloud queue. Each PC delays its posts until its turn. Except for Axel s. Germans are renowned for the ability to get
      Message 2 of 13 , Mar 3 2:28 PM
      • 0 Attachment
        Yes,

        Microsoft's latest invention, the "cloud" queue. Each PC delays its posts until its turn. Except for Axel's. Germans are renowned for the ability to get to the head of the Q. (;-) The German National Motto, "Ich drängel doch nich!" is heard at every train, bus, and theater door.

        Just kidding Axel.

        Prost.

        PS
        actually, there might be a grain of truth to this motto. Back in the early 1920's the German Gubmint issued new money so fast, that people were getting paid twice a day, and rushed right to the store to spend it, as it would lose value so fast, that in the morning you might be able to buy a loaf of bread, and by lunch time, you would be lucky to get a slice from that loaf for the same money.

        Before the off-topic police cranks their recliner forward, lets make this a clip:

        H="Calculate Daily Inflation"
        ^!Set %lunchtimeprice%=^?[Enter price at lunchtime]
        ^!Set %breakfastprice%=^?[Enter price at breakfast]
        ^!Set %inflation%=^$Calc(100*(^%lunchtimeprice%/^%breakfastprice%-1))$
        ^!Info [L]Today's inflation was ^%inflation% percent.

        Eb

        --- In ntb-clips@yahoogroups.com, Ray Shapp <rayshapp@...> wrote:
        > ...

        > Thanks to all who responded - Axel, Don, Eb, Sheri. (Did you notice that you
        > folks replied in alphabetical order?)
        >
      • Art Kocsis
        Hi Ray, Short answer: Do now. Long answer: Other posters have already beat me to the punch to use the join/split commands to solve your problem. I use that
        Message 3 of 13 , Mar 6 11:55 AM
        • 0 Attachment
          Hi Ray,

          Short answer: Do now.

          Long answer:

          Other posters have already beat me to the punch to use the join/split
          commands to solve your problem. I use that technique quite frequently.

          Since I like to keep my original formatting, I add a unique temporary
          character (such as %, &, #, etc) to the end of each non-empty line before
          executing the join command and put two of these characters at the end
          of the last line in each group. After sorting, the original formatting is
          easily
          restored by simply replacing each temporary character with a CRLF. This
          also restores the empty line between groups.

          Although it is pretty simple to do manually, a clip makes it even simpler so
          why not dash off a quick clip? Answer: there is no such thing as a quick clip!

          Not wanting to publish a clip that was not robust and did not handle abnormal
          conditions, I ran into three problems:
          - Multiple separator lines
          - Oddities of high-bit characters
          - Real life demands on my time

          RegEx to the rescue for the first problem!

          The second problem comes from wanting to use a temp character that would
          have a very low probability of appearing in the document and a difference in
          "mindset" between me and Notetab. To me high-bit characters such as thorn
          (alt 0254) are special characters similar to &, #, etc but to Notetab they are
          regular characters, i.e., they are word characters. So it is not a bug in
          NT after
          all that it can find a @ in @@ but cannot find a þ in þþ without the T option!

          The third problem is self explanatory.

          Interestingly, it turns out that I had written a clip to do this very thing
          over two
          years ago and forgot about it. I was pleased to see that I have made a bit of
          progress in my coding, especially in the use of RegEx.

          To the curious, I avoid "GoTos" unless absolutely necessary as it makes for
          much more readable and error-free code.
          ##################### Code follows: ###################
          Sort Groups

          ;Clip to sort (ascending), groups of lines of text, each group
          ; consisting of one or more lines with each line terminated by an
          ; EOL, and each group of lines separated by one or more blank lines
          ;
          ;Note: This clip will affect either preselected text only
          ; or the entire document if no text is preselected
          ;Note: the temporary character "þ" (Thorn, ANSI 254 = ALT 0254),
          ; must not occur at any place in the selected text.
          ;Note: "þ" is a word character, hence requires the "T" ^!Find option
          ; #, @, $, %, etc are non-word chars & do not require the T option
          ;Note: If you want to keep the group spacing for all groups, make sure
          ; you include the CRLF on the last line

          ;Rev History
          ;03-06-11 Created Clip

          ^!StatusShow Running Group Sort
          ^!SetScreenUpdate Off
          ;^!SetDebug On

          ^!Set %SlctSz%=^$GetSelSize$
          ^!If ^%SlctSz%=0 ^!Jump Doc_Start
          ^!Find "þ" HST

          ^!IfError Safe
          ^!Continue Error: Text to be sorted contains internal test character "þ",
          exiting clip
          ^!Goto End

          :Safe
          ^!If ^%SlctSz%>0 ^!Replace "^P" >> "þ" AISTH
          ^!If ^%SlctSz%>0 ^!Replace "þ{2,}" >> "þ\r\n" AIRSTH
          ^!If ^%SlctSz%=0 ^!Replace "^P" >> "þ" AISTW
          ^!If ^%SlctSz%=0 ^!Replace "þ{2,}" >> "þ\r\n" AIRSTW
          ^!Toolbar Sort Ascending
          ^!Replace "þ" >> "^P" AISTH
          ^!If ^%SlctSz%=0 ^!Jump Doc_Start

          ^!Continue Align Left or Cancel?
          ^!Toolbar Left Align

          ^!SetDebug Off
          ##################### Code complete ##################

          Namaste', Art

          At 03/02/2011 11:26, Ray wrote:
          >To All,
          >
          >My question: Do we have any clips in the Fookes libraries that would sort
          >multi-line blocks of text based on a unique key sequence such as I have
          >described?
        • Ray Shapp
          Hello Art, That s a major piece of work. I ll definitely use it. Many thanks! Ray Shapp ... [Non-text portions of this message have been removed]
          Message 4 of 13 , Mar 7 1:32 PM
          • 0 Attachment
            Hello Art,

            That's a major piece of work. I'll definitely use it.

            Many thanks!

            Ray Shapp


            On Sun, Mar 6, 2011 at 2:55 PM, Art Kocsis <artkns@...> wrote:

            >
            >
            > Hi Ray,
            >
            > Short answer: Do now.
            >
            > Long answer:
            >
            > Other posters have already beat me to the punch to use the join/split
            > commands to solve your problem. I use that technique quite frequently.
            >
            > Since I like to keep my original formatting, I add a unique temporary
            > character (such as %, &, #, etc) to the end of each non-empty line before
            > executing the join command and put two of these characters at the end
            > of the last line in each group. After sorting, the original formatting is
            > easily
            > restored by simply replacing each temporary character with a CRLF. This
            > also restores the empty line between groups.
            >
            > Although it is pretty simple to do manually, a clip makes it even simpler
            > so
            > why not dash off a quick clip? Answer: there is no such thing as a quick
            > clip!
            >
            > Not wanting to publish a clip that was not robust and did not handle
            > abnormal
            > conditions, I ran into three problems:
            > - Multiple separator lines
            > - Oddities of high-bit characters
            > - Real life demands on my time
            >
            > RegEx to the rescue for the first problem!
            >
            > The second problem comes from wanting to use a temp character that would
            > have a very low probability of appearing in the document and a difference
            > in
            > "mindset" between me and Notetab. To me high-bit characters such as thorn
            > (alt 0254) are special characters similar to &, #, etc but to Notetab they
            > are
            > regular characters, i.e., they are word characters. So it is not a bug in
            > NT after
            > all that it can find a @ in @@ but cannot find a � in �� without the T
            > option!
            >
            > The third problem is self explanatory.
            >
            > Interestingly, it turns out that I had written a clip to do this very thing
            >
            > over two
            > years ago and forgot about it. I was pleased to see that I have made a bit
            > of
            > progress in my coding, especially in the use of RegEx.
            >
            > To the curious, I avoid "GoTos" unless absolutely necessary as it makes for
            > much more readable and error-free code.
            > ##################### Code follows: ###################
            > Sort Groups
            >
            > ;Clip to sort (ascending), groups of lines of text, each group
            > ; consisting of one or more lines with each line terminated by an
            > ; EOL, and each group of lines separated by one or more blank lines
            > ;
            > ;Note: This clip will affect either preselected text only
            > ; or the entire document if no text is preselected
            > ;Note: the temporary character "�" (Thorn, ANSI 254 = ALT 0254),
            > ; must not occur at any place in the selected text.
            > ;Note: "�" is a word character, hence requires the "T" ^!Find option
            > ; #, @, $, %, etc are non-word chars & do not require the T option
            > ;Note: If you want to keep the group spacing for all groups, make sure
            > ; you include the CRLF on the last line
            >
            > ;Rev History
            > ;03-06-11 Created Clip
            >
            > ^!StatusShow Running Group Sort
            > ^!SetScreenUpdate Off
            > ;^!SetDebug On
            >
            > ^!Set %SlctSz%=^$GetSelSize$
            > ^!If ^%SlctSz%=0 ^!Jump Doc_Start
            > ^!Find "�" HST
            >
            > ^!IfError Safe
            > ^!Continue Error: Text to be sorted contains internal test character "�",
            > exiting clip
            > ^!Goto End
            >
            > :Safe
            > ^!If ^%SlctSz%>0 ^!Replace "^P" >> "�" AISTH
            > ^!If ^%SlctSz%>0 ^!Replace "�{2,}" >> "�\r\n" AIRSTH
            > ^!If ^%SlctSz%=0 ^!Replace "^P" >> "�" AISTW
            > ^!If ^%SlctSz%=0 ^!Replace "�{2,}" >> "�\r\n" AIRSTW
            > ^!Toolbar Sort Ascending
            > ^!Replace "�" >> "^P" AISTH
            > ^!If ^%SlctSz%=0 ^!Jump Doc_Start
            >
            > ^!Continue Align Left or Cancel?
            > ^!Toolbar Left Align
            >
            > ^!SetDebug Off
            > ##################### Code complete ##################
            >
            > Namaste', Art
            >
            > At 03/02/2011 11:26, Ray wrote:
            > >To All,
            >
            > >
            > >My question: Do we have any clips in the Fookes libraries that would sort
            > >multi-line blocks of text based on a unique key sequence such as I have
            > >described?
            >
            >
            >


            [Non-text portions of this message have been removed]
          Your message has been successfully submitted and would be delivered to recipients shortly.