Advertisement
Cookie042

CharacterCounter

Mar 6th, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. +q::
  2. Gui, Counter:New,, CharacterCounter
  3. Gui, Add, Edit, x10 y10 w210 h350 vEditInput
  4. Gui, Add, Edit, x272 y10 w210 h350 vOutput
  5. Gui, Add, Button, x222 y160 w50 h70 gcnt, --->
  6. Gui, Show, w499 h379,
  7. return
  8.  
  9. cnt:
  10. data := []
  11. Gui, Submit, NoHide
  12.  
  13. ;remove deadspace and format for ease of use
  14. StringReplace, EditInput, EditInput, %A_SPACE%,, All
  15. StringReplace, EditInput, EditInput, %A_Tab%,, All
  16. StringReplace, EditInput, EditInput, _,, All
  17. StringReplace, EditInput, EditInput, #,, All
  18. StringReplace, EditInput, EditInput, QTY,%A_Space%, All
  19. StringReplace, EditInput, EditInput, x,%A_Space%, All
  20.  
  21. lines := StrSplit(EditInput,"`n") ;get lines
  22. for k, line in lines
  23. {
  24.     div := StrSplit(line,A_Space)
  25.     txt := div[1]
  26.     val := div[2]
  27.  
  28.     loop % StrLen(txt)
  29.     {
  30.         char := SubStr(txt,A_Index,1)
  31.         if data[char] is number
  32.         {
  33.             data[char] += val
  34.         }
  35.         else
  36.         {
  37.             data[char] := val
  38.         }
  39.     }
  40. }
  41.  
  42. str =
  43. for k, dat in data
  44.     str .= "`'" . k . "`'" . " = " . dat . "`n"
  45.  
  46. GuiControl,, Output, %str%
  47. return
  48.  
  49. GuiClose:
  50. gui, Destroy
  51. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement