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

Re: [NTS] sort R2L, count dupes

Expand Messages
  • jonas_ramus
    ... Running the clip below against... hus hus hus hus2 hus2 hus345 hus345 hus345 hus345 hire uni unity the result is... hus2 2 hus2 2 hus345 4 hus345 4 hus345
    Message 1 of 11 , Apr 7, 2012
    • 0 Attachment
      --- In ntb-scripts@yahoogroups.com, "milan.boran@..." <milan.boran@...> wrote:
      >
      > ### Before ###
      > hus
      > hus
      > hus
      > hus2
      > hus2
      > hus345
      > hus345
      > hus345
      > hus345
      > hire
      > uni
      > unity
      >
      > ### After ###...


      Running the clip below against...

      hus
      hus
      hus
      hus2
      hus2
      hus345
      hus345
      hus345
      hus345
      hire
      uni
      unity

      the result is...

      hus2 2
      hus2 2
      hus345 4
      hus345 4
      hus345 4
      hus345 4
      hire 1
      uni 1
      hus 3
      hus 3
      hus 3
      unity 1

      I hope this is matching your needs. The clip:

      ^!Menu Edit/Copy All
      ^!Toolbar Paste New
      ^!RunGawk "gawk reverse characters"
      ^!Delay 5
      ^!Select All
      ^$StrSort("^$GetSelection$";0;1;0)$
      ^!RunGawk "gawk reverse characters"
      ^!Jump 1
      ^!SetScreenUpdate Off

      :Loop
      ^!Jump Line_End
      ^!InsertText ^%SPACE%^$StrCount("^$GetLine$";"^$GetText$";0;1)$
      ^!Jump +1
      ^!IfEmpty ^$GetLine$ End Else Loop

      where the GAWK script -- placed in a subsclip named 'gawk reverse characters' -- is...

      # Reverse characters on each line
      BEGIN { FS = "" }
      {
      for (i=NF;i>0;i--) printf("%s",$i)
      printf("\%s",RT)
      }

      The GAWK script is quite fast but the counting of occurrences could be rather slow depending on the amount of lines. Maybe someone could deliver a faster solution for that.

      Regards,
      Flo
    • milan.boran@gmail.com
      Hi Flo Doing this the 1st time, do I put this into a text file and name it somehow and load it as a clip or so into NoteTab? Please advise. ... What should I
      Message 2 of 11 , Apr 7, 2012
      • 0 Attachment
        Hi Flo

        Doing this the 1st time, do I put this into a text file and name it
        somehow and load it as a clip or so into NoteTab? Please advise.

        > ^!Menu Edit/Copy All
        > ^!Toolbar Paste New
        > ^!RunGawk "gawk reverse characters"
        > ^!Delay 5
        > ^!Select All
        > ^$StrSort("^$GetSelection$";0;1;0)$
        > ^!RunGawk "gawk reverse characters"
        > ^!Jump 1
        > ^!SetScreenUpdate Off
        >
        > :Loop
        > ^!Jump Line_End
        > ^!InsertText ^%SPACE%^$StrCount("^$GetLine$";"^$GetText$";0;1)$
        > ^!Jump +1
        > ^!IfEmpty ^$GetLine$ End Else Loop
        >

        > where the GAWK script -- placed in a subsclip named 'gawk reverse characters' -- is...
        What should I do here? Save this following part as a subclip? But what
        does that mean, a subroutine, I know, but in terms of action, save it
        in a text file and then put it where?

        > # Reverse characters on each line
        > BEGIN { FS = "" }
        > {
        > for (i=NF;i>0;i--) printf("%s",$i)
        > printf("\%s",RT)
        > }

        This is great stuff. Just need to figure out the last steps.

        Many thanks for this Easter present,
        Milan





        On Sat, Apr 7, 2012 at 23:22, jonas_ramus <flo.gehrke@...> wrote:
        >
        >
        >
        > --- In ntb-scripts@yahoogroups.com, "milan.boran@..." <milan.boran@...> wrote:
        > >
        > > ### Before ###
        > > hus
        > > hus
        > > hus
        > > hus2
        > > hus2
        > > hus345
        > > hus345
        > > hus345
        > > hus345
        > > hire
        > > uni
        > > unity
        > >
        > > ### After ###...
        >
        > Running the clip below against...
        >
        >
        > hus
        > hus
        > hus
        > hus2
        > hus2
        > hus345
        > hus345
        > hus345
        > hus345
        > hire
        > uni
        > unity
        >
        > the result is...
        >
        >
        > hus2 2
        > hus2 2
        > hus345 4
        > hus345 4
        > hus345 4
        > hus345 4
        > hire 1
        > uni 1
        > hus 3
        > hus 3
        > hus 3
        > unity 1
        >
        > I hope this is matching your needs. The clip:
        >
        > ^!Menu Edit/Copy All
        > ^!Toolbar Paste New
        > ^!RunGawk "gawk reverse characters"
        > ^!Delay 5
        > ^!Select All
        > ^$StrSort("^$GetSelection$";0;1;0)$
        > ^!RunGawk "gawk reverse characters"
        > ^!Jump 1
        > ^!SetScreenUpdate Off
        >
        > :Loop
        > ^!Jump Line_End
        > ^!InsertText ^%SPACE%^$StrCount("^$GetLine$";"^$GetText$";0;1)$
        > ^!Jump +1
        > ^!IfEmpty ^$GetLine$ End Else Loop
        >
        > where the GAWK script -- placed in a subsclip named 'gawk reverse characters' -- is...
        >
        > # Reverse characters on each line
        > BEGIN { FS = "" }
        > {
        > for (i=NF;i>0;i--) printf("%s",$i)
        > printf("\%s",RT)
        > }
        >
        > The GAWK script is quite fast but the counting of occurrences could be rather slow depending on the amount of lines. Maybe someone could deliver a faster solution for that.
        >
        > Regards,
        > Flo
        >
        >




        --




        ----------
        Legal Note
        This message, incl. potential attachments, is of confidential or
        privileged nature and intended solely for individual/organization
        addressed. If received in error, please notify sender at once and
        destroy. Unintended use of message is forbidden/potentially illegal.
        Salvatory and severance apply, estoppel is void, e.g. in that any
        message or any part thereof shall be valid in their own context.
        ----------
      • flo.gehrke
        ... Milan, ... Copy the clip to clipboard, open any clipbook, and insert the clip with Add from clipboard (using the context menu inside the left pane of the
        Message 3 of 11 , Apr 7, 2012
        • 0 Attachment
          --- In ntb-scripts@yahoogroups.com, "milan.boran@..." <milan.boran@...> wrote:
          >
          > Hi Flo

          Milan,

          > Doing this the 1st time, do I put this into a text file and name it
          > somehow and load it as a clip or so into NoteTab? Please advise.

          Copy the clip to clipboard, open any clipbook, and insert the clip with 'Add from clipboard' (using the context menu inside the left pane of the clipbook).

          >> where the GAWK script -- placed in a subsclip named 'gawk reverse characters'
          >> is...
          > What should I do here? Save this following part as a subclip? But what
          > does that mean, a subroutine, I know, but in terms of action, save it
          > in a text file and then put it where?

          Same procedure as above. Please note: You may name the main clip with any name whereas the subclip must be named 'gawk reverse characters' according with the subclip call.

          For more details, see the 'Help on Clip Programming' | Executing Programs | Using Perl, GAWK, and Other Scripts'.

          Regards,
          Flo
        • milan.boran@gmail.com
          Yes, this problem has been solved. Many thanks to all who helped, especially Don, Flo, Jonas, and Thomas. Best regards, Milan ... -- ... Legal Note This
          Message 4 of 11 , Apr 20, 2012
          • 0 Attachment
            Yes, this problem has been solved.

            Many thanks to all who helped, especially
            Don, Flo, Jonas, and Thomas.

            Best regards,
            Milan





            On Sun, Apr 8, 2012 at 05:45, flo.gehrke <flo.gehrke@...> wrote:
            >
            >
            >
            > --- In ntb-scripts@yahoogroups.com, "milan.boran@..." <milan.boran@...> wrote:
            > >
            > > Hi Flo
            >
            > Milan,
            >
            >
            > > Doing this the 1st time, do I put this into a text file and name it
            > > somehow and load it as a clip or so into NoteTab? Please advise.
            >
            > Copy the clip to clipboard, open any clipbook, and insert the clip with 'Add from clipboard' (using the context menu inside the left pane of the clipbook).
            >
            >
            > >> where the GAWK script -- placed in a subsclip named 'gawk reverse characters'
            > >> is...
            > > What should I do here? Save this following part as a subclip? But what
            > > does that mean, a subroutine, I know, but in terms of action, save it
            > > in a text file and then put it where?
            >
            > Same procedure as above. Please note: You may name the main clip with any name whereas the subclip must be named 'gawk reverse characters' according with the subclip call.
            >
            > For more details, see the 'Help on Clip Programming' | Executing Programs | Using Perl, GAWK, and Other Scripts'.
            >
            > Regards,
            > Flo
            >
            >




            --




            ----------
            Legal Note
            This message, incl. potential attachments, is of confidential or
            privileged nature and intended solely for individual/organization
            addressed. If received in error, please notify sender at once and
            destroy. Unintended use of message is forbidden/potentially illegal.
            Salvatory and severance apply, estoppel is void, e.g. in that any
            message or any part thereof shall be valid in their own context.
            ----------
          Your message has been successfully submitted and would be delivered to recipients shortly.