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

Totalling using clipboard

Expand Messages
  • dvdwriters12
    Does anyone know or have a clip to sum up values you copy to the clipboard and return the result in the clipboard ?
    Message 1 of 10 , Oct 1, 2006
    • 0 Attachment
      Does anyone know or have a clip to sum up values you copy to the clipboard and return the result in the clipboard ?
    • mblattyh
      ... clipboard and return the result in the clipboard ? ... I d think the clip would be dependent on the format/layout of the numbers you copy to the clipboard.
      Message 2 of 10 , Oct 2, 2006
      • 0 Attachment
        --- In ntb-clips@yahoogroups.com, "dvdwriters12" <dvdwriters@...>
        wrote:
        >
        > Does anyone know or have a clip to sum up values you copy to the
        clipboard and return the result in the clipboard ?
        >

        I'd think the clip would be dependent on the format/layout of the
        numbers you copy to the clipboard. I had a need to sum numbers that
        were in a row, separated by spaces. This clip does that, and just
        displays the sum in an info box, but copying it to the clipboard
        shouldn't be difficult. I would also guess that there's a much more
        elegant way to do this.

        ; copy selection to variable
        ^!Set %var1%="^$GetSelection$"
        ; change spaces to + signs
        ^!Set %var2%=^$StrReplace(" ";"+";"^%var1%";True;False)$
        ; turn multiple + signs in a row into a single + sign
        ^!Set %var2%=^$StrReplace("++";"+";"^%var2%";True;False)$
        ^!Set %var2%=^$StrReplace("++";"+";"^%var2%";True;False)$
        ^!Set %var2%=^$StrReplace("++";"+";"^%var2%";True;False)$
        ; remove trailing plus signs
        :checkplus
        ^!If "^$StrCopyRight("^%var2%";1)$"="+" plusend ELSE docalc
        :plusend
        ^!Set %var2%=^$StrDeleteRight("^%var2%";1)$
        ^!Goto checkplus
        ; display calculated sum
        :docalc
        ^!Info "Sum of highlighted numbers is ^$calc(^%var2%)$"
      • hsavage
        ... dvdwriters12, A valid point is made above, much depends on the format, row/column/etc. of the numbers you want to sum. If they are in a row, we need the
        Message 3 of 10 , Oct 2, 2006
        • 0 Attachment
          mblattyh wrote:
          > --- In ntb-clips@yahoogroups.com, "dvdwriters12" <dvdwriters@...>
          > wrote:
          >> Does anyone know or have a clip to sum up values you copy to the
          > clipboard and return the result in the clipboard ?
          >
          > I'd think the clip would be dependent on the format/layout of the
          > numbers you copy to the clipboard. I had a need to sum numbers that
          > were in a row, separated by spaces.

          dvdwriters12,

          A valid point is made above, much depends on the format, row/column/etc.
          of the numbers you want to sum. If they are in a row, we need the
          separator/delimiter.

          Below is a quickly written clip to sum columnar numbers. You can delete
          or rem out the ^!Info [L] line if you don't need a visual display.

          **********************
          H="Sum Selected Column To ClipBoard"
          ;_ Modified-Updated~Created_20061002
          ;_ hrs ø hsavage·pobox·com_12:58:50p
          ^!SetScreenUpdate 0
          ;
          ^!SetClipboard ^$StrTrim("^$GetSelection$")$
          ^!ToolBar Paste NEW
          ^!Menu Modify/Lines/Compress
          ;^!Menu Modify/Alignment/Left Align
          ^!Set %var%=^$StrReplace("^p";"+";"^$GetSelection$";0;0)$
          ^!SetClipboard ^$Calc(^%var%;0)$
          ^!Close DISCARD
          ^!Info [L]^$GetClipboard$
          **********************

          ºvº
          2006.10.02
          -Newspaper HeadLine...
          "British Left Waffles on Falkland Islands"
          hrs ø hsavage@...
        • hsavage
          ... dvdwriters12, Below is a slightly modified clip to return focus to the document the numbers were copied from. ********************** H= Sum Columns To
          Message 4 of 10 , Oct 2, 2006
          • 0 Attachment
            hsavage wrote:
            > mblattyh wrote:
            >> --- In ntb-clips@yahoogroups.com, "dvdwriters12" <dvdwriters@...>
            >> wrote:
            >>> Does anyone know or have a clip to sum up values you copy to the
            >> clipboard and return the result in the clipboard ?
            >>
            >> I'd think the clip would be dependent on the format/layout of the
            >> numbers you copy to the clipboard. I had a need to sum numbers that
            >> were in a row, separated by spaces.
            >
            > dvdwriters12,
            >
            > A valid point is made above, much depends on the format, row/column/etc.
            > of the numbers you want to sum. If they are in a row, we need the
            > separator/delimiter.
            >
            > Below is a quickly written clip to sum columnar numbers. You can delete
            > or rem out the ^!Info [L] line if you don't need a visual display.

            dvdwriters12,

            Below is a slightly modified clip to return focus to the document the
            numbers were copied from.

            **********************
            H="Sum Columns To ClipBoard"
            ;_ Modified-Updated~Created_20061002
            ;_ hrs ø hsavage·pobox·com_12:58:50p
            ^!SetScreenUpdate 0
            ^!Set %doc_idx%=^$GetExpandedName(^##)$
            ;
            ^!SetClipboard ^$StrTrim("^$GetSelection$")$
            ^!ToolBar Paste NEW
            ^!Menu Modify/Lines/Compress
            ;^!Menu Modify/Alignment/Left Align
            ^!Set %var%=^$StrReplace("^p";"+";"^$GetSelection$";0;0)$
            ^!SetClipboard ^$Calc(^%var%;0)$
            ^!Close DISCARD
            ^!SetDocIndex ^$GetDocIndex(^%doc_idx%)$
            ^!Info [L]^$GetClipboard$
            **********************

            ºvº
            2006.10.02
            -Newspaper HeadLine...
            "British Left Waffles on Falkland Islands"
            hrs ø hsavage@...
          • dvdwriters12
            Thanks, I should have been more clear. Suppose I am working in another document and we have a price list: £521.12 £100 £37.02 £912.11 £0.99 TOTAL = £
            Message 5 of 10 , Oct 2, 2006
            • 0 Attachment
              Thanks,

              I should have been more clear.

              Suppose I am working in another document and we have a price list:

              £521.12

              £100

              £37.02

              £912.11

              £0.99

              TOTAL = £

              etc.

              I want to copy each price into the clipboard and have notetab in the
              background accumulate the value and return the result in the
              clipboard, without me switching to notetab.

              Ive tried but I dont think its possible.
            • hsavage
              ... dvdwriters12, A few questions. Do you want to select each number individually or a column of numbers? Are the numbers always in a column, as in the
              Message 6 of 10 , Oct 2, 2006
              • 0 Attachment
                dvdwriters12 wrote:
                > Thanks,
                >
                > I should have been more clear.
                >
                > Suppose I am working in another document and we have a price list:
                >
                > £521.12
                >
                > £100
                >
                > £37.02
                >
                > £912.11
                >
                > £0.99
                >
                > TOTAL = £
                >
                > etc.
                >
                > I want to copy each price into the clipboard and have notetab in the
                > background accumulate the value and return the result in the
                > clipboard, without me switching to notetab.
                >
                > Ive tried but I dont think its possible.

                dvdwriters12,

                A few questions.

                Do you want to select each number individually or a column of numbers?

                Are the numbers always in a column, as in the example?

                Are the numbers always at the left margin as in the example?

                Will the numbers always have the currency symbol included?

                Do you deal in other currencies other than pounds, if so, which?

                Possibly more questions later, depending on the answers to these.

                ºvº
                2006.10.02
                -Newspaper HeadLine...
                "British Union Finds Dwarfs in Short Supply"
                hrs ø hsavage@...
              • Don - HtmlFixIt.com
                = V5 MultiLine NoSorting TabWidth=30 H= ;About this library ; Clip by Don at htmlfixit dot com If you start this thing and then paste numbers to the
                Message 7 of 10 , Oct 2, 2006
                • 0 Attachment
                  = V5 MultiLine NoSorting TabWidth=30

                  H=";About this library"
                  ; Clip by Don at htmlfixit dot com
                  If you start this thing and then paste numbers to the clipboard, you'll
                  get the total of those numbers back on the clipboard when you are done.

                  If you copy something that is not a number, then you get the total of
                  all copied numbers to the clipboard.

                  The next time you copy a number, it will continue on fresh.

                  H=";"


                  H="Start"
                  ;start fresh
                  ^!ClearVariables
                  ;Set initial values for main variables
                  ^!Set %CheckClipboard%=True; %PasteInfo%=0
                  ;If user does not want to create a new document, skip this procedure
                  :SkipNewDoc
                  ^!Prompt Number copy mode is now enabled to total all numbers copied,
                  copy an non-number to have get the total to the clipboard.

                  H="Stop"
                  ;Stop checking the Windows Clipboard
                  ^!Set %CheckClipboard%=False
                  ^!Prompt Number capturing stopped. Double-click on the "Start" Clip if
                  you want to continue

                  H="_OnClipboardChange"
                  ;If we are not supposed to check the Windows Clipboard, end this Clip
                  ^!IfFalse ^%CheckClipboard% End
                  ;If the size of the text in the Clipboard exceeds 255 characters, end
                  this Clip (unlikely to be a number)
                  ^!If ^$GetClipboardSize$ > 255 End
                  ;Copy Clipboard text into a variable
                  ^!Set %ClipboardText%=^$GetClipboard$
                  ;if not number, prompt for whether to continue or end the clip
                  ^!If "^$IsNumber("^%ClipboardText%")$" = "1" NUMBER ELSE TOTAL
                  :NUMBER
                  ;Play sound file if it exists
                  ^!Sound ^$GetSoundPath$SayInfo.wav

                  ;MESSAGE
                  ^!Set %subtotal%=^$Calc(^%subtotal%+^%ClipboardText%)$
                  ^!Set %PasteInfo%=0
                  ;End the Clip
                  ^!Goto End

                  :TOTAL
                  ^!SetClipboard ^%subtotal%
                  ^!ClearVariable %subtotal%

                  ;End the Clip
                  ^!Goto End
                • Don - HtmlFixIt.com
                  ... It just occurred to me, didn t we have a discussion a while back that you cannot trust isNumber? If so I may need to fine tune this thing a little. I
                  Message 8 of 10 , Oct 3, 2006
                  • 0 Attachment
                    Don - HtmlFixIt.com wrote:
                    > = V5 MultiLine NoSorting TabWidth=30
                    >
                    > H=";About this library"
                    > ; Clip by Don at htmlfixit dot com
                    > If you start this thing and then paste numbers to the clipboard, you'll
                    > get the total of those numbers back on the clipboard when you are done.
                    >
                    > If you copy something that is not a number, then you get the total of
                    > all copied numbers to the clipboard.
                    >
                    > The next time you copy a number, it will continue on fresh.
                    >

                    It just occurred to me, didn't we have a discussion a while back that
                    you cannot trust isNumber? If so I may need to fine tune this thing a
                    little. I could be off here, does anyone else remember that discussion?

                    I didn't test my clip on anything but whole numbers.

                    When I started this clip, one of the ones I was looking at to remember
                    the onClipBoardChange bit was one I worked on in 2002. So I've seen a
                    lot of clips and I forget more than I remember probably :-)
                  • dvdwriters12
                    ... remember ... a ... Thanks Don, Yeah as you say it doesnt work on fractional numbers, but otherwise it seems to work except it doesnt return the result in
                    Message 9 of 10 , Oct 3, 2006
                    • 0 Attachment
                      >
                      > I didn't test my clip on anything but whole numbers.
                      >
                      > When I started this clip, one of the ones I was looking at to
                      remember
                      > the onClipBoardChange bit was one I worked on in 2002. So I've seen
                      a
                      > lot of clips and I forget more than I remember probably :-)
                      >


                      Thanks Don,

                      Yeah as you say it doesnt work on fractional numbers, but otherwise it
                      seems to work except it doesnt return the result in the clipboard
                      (which is easy enough to modify).
                    • Don - HtmlFixIt.com
                      ... I have the solution around here to get it to work on fractional numbers. I ll try to do that when I get a second. It should be putting the result on the
                      Message 10 of 10 , Oct 3, 2006
                      • 0 Attachment
                        > Thanks Don,
                        >
                        > Yeah as you say it doesnt work on fractional numbers, but otherwise it
                        > seems to work except it doesnt return the result in the clipboard
                        > (which is easy enough to modify).

                        I have the solution around here to get it to work on fractional numbers.
                        I'll try to do that when I get a second.

                        It should be putting the result on the clipboard. When you are done
                        totaling copy a non-number and you should have the result on the clipboard.

                        Try that again and let me know if it is working. If not, I'll have to
                        revisit. I should add that I am working in 4.95 pro.
                      Your message has been successfully submitted and would be delivered to recipients shortly.