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

Re: Re: Clip for sorting comma separated numbers

Expand Messages
  • Amitava Das Gupta
    Hi everybody, Thanks for all the responses to my problem. Both Hugo s and Charlie s clips work fine. I don t know which one to keep. Guess I ll file both away.
    Message 1 of 7 , Mar 29, 2006
      Hi everybody,

      Thanks for all the responses to my problem. Both Hugo's and Charlie's
      clips work fine. I don't know which one to keep. Guess I'll file both
      away. I had been working on the lines of Charlie's method, and had
      managed to add the leading zeros. Sorting the list after that worked
      perfectly of course. However I spent half of last night trying to figure
      out a way to strip the leading zeros after the sorting was done. Never
      occurred to me to add another zero to the number. Hugo's clip, in spite
      of his opinion, is elegant enough for me ;-). Its short and does the
      work, and as Don said the trick of right-aligning the text is amazing. I
      don't have the problem with the bug when replacing ^p with commas, as I
      use NTP.

      Once again, thanks a lot for all your help,

      Amitava

      > Message: 1
      > Date: Mon, 27 Mar 2006 21:27:00 +0200
      > From: Hugo Paulissen <hugopaulissen@...>
      > Subject: Re: Clip for sorting comma separated numbers
      >

      > Hi Amitava,
      >
      > That is not an easy task (because of the unintelligent sorting method).
      > Here is a "not-so-elegant solution", drafted together without too much
      > thought.
      > The trick is that I right-align the selected text, sort, and left align
      > again.
      >
      > ^!SetScreenUpdate OFF
      > ^!Set %nospaces%=^$strReplace(" ";"";"^$GetSelection$";0;0)$
      > ^!Set %newlines%=^$strReplace(",";"^p";"^%nospaces%";0;0)$
      > ^!Keyboard Ctrl+N
      > ^%newlines%
      > ^!Select ALL
      > ^!Keyboard ALT+M A R
      > ^!Keyboard ALT+M L S A
      > ^!Keyboard ALT+M A L
      > ^!SetClipboard ^$strTrim(^$GetSelection$)$
      > ^!Keyboard CTRL+F4 N
      > ^!INFO You can paste this row^pinto the original document^p^$GetClipboard$
      >
      > HTH,
      >
      > Hugo
      >

      > Message: 4
      > Date: Mon, 27 Mar 2006 20:53:08 -0600
      > From: "Charles M. Raine" <rainec@...>
      > Subject: Re: Clip for sorting comma separated numbers
      >
      > Hi Amitava:

      > Here is a working solution to your question:
      >
      > H="Sort Numbers"
      > ;Amitava Das Gupta <amitav@...>
      > ;03/27/2006, 05:56:40 PM
      > ^!Set %list%=^$GetClipBoard$^%NL%
      > ^!Set %list%="^$StrReplace(",^p";"^P";"^%list%";Yes;Yes)$"
      > ^!Set %list%="^$StrReplace(", ";"^P";"^%list%";Yes;Yes)$"
      > ^!Set %File%=^$GetTempFile$
      > ^!Open ^%File%
      > ^!InsertText ^%list%
      > ^!Set %cnt%=^$GetLineCount$
      > ^!Set %idx%=1
      > :Again
      > ^!SetCursor ^%idx%:0
      > ^!If ^$GetLineSize(^%idx%)$=4 Skip_2
      > ^!Jump ^%idx%
      > ^!InsertText ^$StrFill("0";^$Calc(4-^$GetLineSize(^%idx%)$)$)$
      > ^!Inc %idx%
      > ^!If ^%idx%=>^%cnt% Skip
      > ^!Goto Again
      > ;^!SetDebug on
      > ^!Select ALL
      > ^!Set %list%=^$GetSelection$
      > ^!Set %listsorted%=^$StrSort("^%list%";no;yes;yes)$
      > ^!InsertText ^%listsorted%
      > ^!Set %idx%=1
      > :Again1
      > ^!SetCursor ^%idx%:0
      > ^!Jump ^%idx%
      > ^!SelectTo ^%idx%:5
      > ^!InsertText ^$Calc(^$GetSelection$+0)$
      > ^!Inc %idx%
      > ^!If ^%idx%=>^%cnt% Skip
      > ^!Goto Again1
      > ^!Select ALL
      > ^!Set %listsorted%=^$GetSelection$
      > ^!Close ^%File%,DISCARD
      > ^!Set %listsorted%=^$StrReplace("^P";", ";"^%listsorted%";No;Yes)$
      > ^!Info ^%listsorted%
      >



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