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

15578Re: Totalling using clipboard

Expand Messages
  • mblattyh
    Oct 2, 2006
      --- In ntb-clips@yahoogroups.com, "dvdwriters12" <dvdwriters@...>
      > 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
      ^!If "^$StrCopyRight("^%var2%";1)$"="+" plusend ELSE docalc
      ^!Set %var2%=^$StrDeleteRight("^%var2%";1)$
      ^!Goto checkplus
      ; display calculated sum
      ^!Info "Sum of highlighted numbers is ^$calc(^%var2%)$"
    • Show all 10 messages in this topic