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

Re: [Clip] Re: Totalling using clipboard

Expand Messages
  • 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 1 of 10 , Oct 2 9:58 PM
      = 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 2 of 10 , Oct 3 5:08 AM
        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 3 of 10 , Oct 3 7:12 AM
          >
          > 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 4 of 10 , Oct 3 7:23 AM
            > 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.