Updated 2017-11-12 21:21:12 by gold

Easy Eye Calculator and eTCL Slot Calculator Demo Example edit

This page is under development. Comments are welcome, but please load any comments in the comments section at the bottom of the page. Please include your wiki MONIKER in your comment with the same courtesy that I will give you. Its very hard to reply intelligibly without some background of the correspondent. Thanks,gold

gold Here is some eTCL starter code for an easy eye calculator, includes large black font on green background. The human eye is peaked for yellow/green and various ergonomic studies have shown that black font on green background is one of the easiest to read. My small notepad has a linked script and icon for easy eye calculator, posted on the windows desktop of small screen, 22 by 12 cm. One advantage of the easy eye calculator is that the calculations are posted to a console window as a sort of paper tape. The easy eye calculations can be cut and paste, saved to a word processor. The easy eye calculator is a compilation of several eval calculators on the TCL wiki.

Improvements No 1: math operator notation

The math operator notation from "namespace path {::tcl::mathop ::tcl::mathfunc}" is available on the green screen. Once the math expression is typed from the keyboard into the green window, the mouse pointer can be set down in the green calculator window and the expression altered. For example, [* 2. 5.0 ] can be altered to [* 2. 5.7777] on the keyboard. I have been unable to screen grab or screen copy the results in the green window, maybe somebody can show how to achieve this. I understand that the TCL console is compiled in a different interpreter or thread than the TCL application, but I would like to forward complex math expressions from the console to the green window. Possibly, entering one symbol like > (right arrow) or ^ (hat) to transfer and expression to the green window. For example, type "> [* 2. 5.7777 ]" or > 2./5. on the keyboard and transfer expression to the green screen. Also, type erase on console and clear green screen.

Improvements No. 2: Added statements for precision and math library.

Note spaces near expr statement must be maintained or program deck will not work, blanks _b here {expr _b <string map {/ *1./} $e>_b } .
        package require math::calculus
        package require math::constants 
        package require math::statistics
        package require math::special
        package require math::numtheory
        set tclprecision 17
        namespace path {::tcl::mathop ::tcl::mathfunc  }

Improvements No. 3, underway from posted Ask, and it shall be given # 12

gold 11 nov 2017, I have a wiki page called Easy Eye Calculator and eTCL Slot Calculator Demo Example, Numerical Analysis . I know I can add a help button to the Windows Wish Console, but is there modify or add to the help:about popup? Thanks, something like
        proc self_helpx {} {
            set msg2 "
            self help
            pi  invoked as [ pi ]
            console, > 1/9  transfer entries to green screen
            console, e>     erase green screen 
            console, q>     quits program
            console, > (2*3)+(3*3)  transfer entries to green screen
            conventional text editor formulas 
            can be pasted into green console 
            and transferred (cmd > )  to green line for calculation. 
            should be space between > and entries
            Note spaces near expr statement must be maintained 
            or program deck will not work, blanks _b must be here
           {expr _b <string map {/ *1./} $e>_b } "
            console eval {.console configure -txt $msg2 }
            } 
        [ self_helpx ]

MG You can use the console eval command to run commands in the console interpreter, and then use a little introspection to find and tweak the menu:
(Mike) 1 % console eval {. config -menu}
-menu menu Menu {} .menubar
(Mike) 2 % console eval {.menubar entrycget "Help" -menu}
.menubar.help
(Mike) 3 % console eval {.menubar.help entryconfig 1 -command}
-command {} {} {} tk::ConsoleAbout
(Mike) 4 % console eval {proc foo {} {.console insert end "\nText Here\n" ; .console see end}}
(Mike) 5 % console eval {.menubar.help entryconfig 1 -command foo}

gold Subroutine so far, similar cosmetics to original console and added label for self_help.
       console eval { proc self_helpx {} {
            set msg "easy eye calculator, large black type on green
            from TCL WIKI,
            self help
            pi  invoked as \[ pi \]
            console, > 1/9  transfer entries to green screen
            console, e>     erase green screen 
            console, q>     quits program
            console, > (2*3)+(3*3)  transfer entries to green screen
            conventional text editor formulas 
            can be pasted into green console 
            and transferred (cmd > )  to green line for calculation. 
            should be space between > and entries
            Note spaces near expr statement must be maintained 
            or program deck will not work
             "
            tk_messageBox -title "self_helpxx" -message $msg } }
        console eval {.menubar.help add command -label Self_help -command self_helpx }

Testcases Section

In planning any software, it is advisable to gather a number of testcases to check the results of the program. The math for the testcases can be checked by pasting statements in the TCL console. Aside from the TCL calculator display, when one presses the report button on the calculator, one will have console show access to the capacity functions (subroutines).

Testcase 1

console, > 1/9
transfer entries to green screen
should be space between > and entries

Testcase 2

console, e>
erase green screen 

Testcase 3

console, q>
quits program

Testcase 4

console, > (2*3)+(3*3)
transfer entries to green screen
should be space between > and entries

Screenshots Section


figure 1.



References:


Appendix Code edit

appendix TCL programs and scripts

        # pretty print from autoindent and ased editor
        # easy eye calculator, large black type on green
        # written on Windows XP on eTCL
        # working under TCL version 8.5.6 and eTCL 1.0.1
        # gold on TCL WIKI , 2may2014
        package require Tk
        package provide calculatorliner 1.0
        namespace path {::tcl::mathop ::tcl::mathfunc}
        set tclprecision 17
        namespace eval liner {
            console show
            proc initdisplay {} {
                pack [entry .e -textvar e -width 50 ]
    bind .e <Return> {puts $e;catch {expr  [string map {/ *1./} $e]   } res; set e $res;puts $res} ;# RS & FR
            }
            }
        proc linershell {} {
            namespace import liner::*
            liner::initdisplay
            .e configure -bg palegreen
            .e configure -fg black
            .e configure -font {helvetica 50 bold}
            .e configure -highlightcolor tan -relief raised -border 30
            focus .e
            wm title . "Easy Eye Calculator"
            proc pi {} {
                expr acos(-1)
            }
            proc > {args}  {
            global e 
            set e $args}
            proc e> {args} {
            global e 
            set e ""}
            proc q> {args} {
            exit}
        }
        bind Label <1> {focus %W}
        
        bind Label <FocusIn> {
            %W configure -background SystemHighlight -foreground SystemHighlightText
        }
        bind Label <FocusOut> {
            %W configure -background SystemButtonFace -foreground SystemButtonText
        }
        bind Label <Control-c> {
            clipboard clear
            clipboard append [%W cget -text]
        }
        bind Label <Control-p> {
            #clipboard clear
            clipboard append [%W cget -text]
        }
        bind Label <Control-q> {
            #clipboard exit
            clipboard append [%W exit]
        }
        console show
        console eval { proc self_helpx {} {
            set msg "easy eye calculator, large black type on green
            from TCL WIKI,
            self help
            pi  invoked as \[ pi \]
            console, > 1/9  transfer entries to green screen
            console, e>     erase green screen 
            console, q>     quits program
            console, > (2*3)+(3*3)  transfer entries to green screen
            conventional text editor formulas 
            can be pasted into green console 
            and transferred (cmd > )  to green line for calculation. 
            should be space between > and entries
            Note spaces near expr statement must be maintained 
            or program deck will not work
             "
            tk_messageBox -title "self_help" -message $msg } }
        console eval {.menubar.help add command -label Self_help -command self_helpx }
        console eval {.console config -bg palegreen}
        console eval {.console config -font {fixed 20 bold}}
        console eval {wm geometry . 40x20}
        linershell         


gold This page is copyrighted under the TCL/TK license terms, this license.

Comments Section edit

Please place any comments here, Thanks.