home *** CD-ROM | disk | FTP | other *** search
/ Dream 46 / Amiga_Dream_46.iso / Linux / Magazine / Tcltk / calc.tcl next >
Text File  |  1997-11-13  |  991b  |  54 lines

  1.  
  2. proc ExecCommand {} {
  3.     global .viewtxt
  4.  
  5.     set calcstring [.viewtxt get "insert linestart" "insert lineend" ]
  6.  
  7.     .viewtxt insert "end" "\n"
  8.     .viewtxt insert "end" [expr $calcstring]
  9.     .viewtxt tag add result "insert linestart" "insert lineend" 
  10.     .viewtxt insert "end" "\n"
  11.  
  12.     .viewtxt see end
  13.  
  14. }
  15.  
  16. proc ExecCommandKey {} {
  17.     global .viewtxt
  18.  
  19.     .viewtxt mark set insert "insert - 1 lines lineend"
  20.  
  21.     set calcstring [.viewtxt get "insert linestart" "insert lineend" ]
  22.  
  23.     .viewtxt insert "end" [expr $calcstring]
  24.     .viewtxt mark set insert "insert + 1 lines lineend" 
  25.     .viewtxt tag add result "insert linestart" "insert lineend" 
  26.     .viewtxt insert "end" "\n"
  27.  
  28.     .viewtxt see end
  29. }    
  30.  
  31. proc ResetCommand {} {
  32.     global .viewtxt
  33.  
  34.     .viewtxt delete 0.0 end
  35. }
  36.  
  37. proc NegateCommand {} {
  38.     global .viewtxt
  39.  
  40.     .viewtxt insert "insert linestart" "-"
  41.     .viewtxt mark set insert "insert lineend"
  42. }
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.