## Easy Eye Calculator and eTCL Slot Calculator Demo Example

gold Here is some eTCL starter code for an easy eye calculator, includes large black font on green background. The 2 line calculator in A little calculator from Richard Suchenwirth et al can be dressed up. 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. The easy eye concept is similar to the more legible screens in the older monochrome green screens and monochrome yellow screens, as well as the old MS-DOS texteditor program Wordstar. 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.

### Not a Replacement for TCL Core

gold Update 3/2/2024. This page on developing pseudocode examples and one line procedures is not a replacement for the current Tcl core and Tcllib, which is much improved since Tcl version 4, and other <faster> language constructs. math ops, Tcllib routines, and other compiled routines can reduce the cost of big-data tasks by about 1/3. The time savings of the core are not always obvious on small quantities of data, like 4 or 5 numbers. Performance of one-line programs may suffer degradation due to lengthy recursion calls, and may be limited by constraints on recursion. Dependence on math operator notation, helper procedures, math check examples, degradation due to lengthy recursion calls, and special library functions should be noted in the comment lines.

#### 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}
(Mike) 3 % console eval {.menubar.help entryconfig 1 -command}
(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 } }

#### Improvements No. 4, invoking Math Libraries in Testbeds

gold 10/25/2020. The easy eye calculator code is the original bare bones display because it was thought that the user could get up and working calculator faster without a lot of tweaks, help button comments, and library references. The shorter the code list, the faster and more reliable is the easy eye calculator. Secondly, the original source code was working on the expired eTcl application for windows, but the installation and compatibility of TCL 8.6 and TCLLIB calls from eTcl and Android apps was uncertain here at that time. Some of the possible improvements and additional code statements for a local setup are listed as auxiliary source code on this page. There are several Wiki pages that show this easy eye calculator used as a testbed for other wiki pages, used to make displays, or linked to TCLLIB library functions. See Compendium [L1 ] and Testbed [L2 ]. Also [L3 ]& [L4 ] & [L5 ]

### Invoking Math Libraries and Self_help button

```        # pretty print from autoindent and ased editor
# easy eye calculator, large black type on green
# used as testbed for one liners programs
# written on Windows 10 on TCL
# working under TCL version 8.6
# gold on TCL WIKI , 10Sep2020
package require Tk
package require math::numtheory
package require math::constants
package require math::trig
package require math
namespace path {::tcl::mathop ::tcl::mathfunc math::numtheory math::trig math::constants }
package provide calculatorliner 1.0
namespace path {::tcl::mathop ::tcl::mathfunc}
set tclprecision 17
# end of initial deck
# ******************* added to bottom of deck ******
# add cosmetics below to bottom of file
# added statements above for math ops and TCLLIB library
console show
console eval {.console config -bg palegreen}
console eval {.console config -font {fixed 20 bold}}
console eval {wm geometry . 40x20}
console eval {wm title . "  easy eye console, screen grab and paste from console 2 to texteditor"}
console eval {. configure -background orange -highlightcolor brown -relief raised -border 30}
console eval { proc self_helpx {} {
set msg "in TCL, large black type on green
from TCL,
self help listing
Conventional text editor formulas grabbed
from internet screens can be pasted
into green console
# testbed  for one liner programs
# suggest maintain dead spaces and air gaps near expr, brackets, etc in following statements
# demo calculator from RS, (wiki 2000-08-21) "
tk_messageBox -title "self_helpxx" -message \$msg } }

#### Improvements No. 5, Buttons on Calculator line display

gold10/26/2020. Buttons for eval, clear, and exit were installed for the Command Line Calculator in Namespace [L6 ]. These buttons could be retrofitted into the easy eye calculator and testbeds in the references.

```                        source easy_eye_calculator.tcl
;# user may be able to paste code at
;# bottom of easy eye calculator and work
;# but am not sure
namespace eval liner {
proc evalwild {e} {
if [catch {set res [expr [string map {/ *1.0/} \$e]]}] {
catch {uplevel #0 eval \$e} res
}
set ::e \$res
}
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
button .a -text eval -command {liner::evalwild \$e}
button .b -text clear -command {set e ""}
button .c -text exit -command {exit}
pack .a .b .c   -side left -padx 5
. configure  -bg palegreen
wm title . "Modified Line Calculator"
}
linershell```

### 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 2. Easy Eye Calculator V2 , modified version

Command Line Calculator in Namespace

## Appendix Code

### appendix TCL programs and scripts

The easy eye calculator code is the original bare bones display because it was thought that the user could get up and working the calculator faster without a lot of tweaks, help button comments, and invoking the TCL and TCLLIB library references.

```        # 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 {.console config -bg palegreen}
console eval {.console config -font {fixed 20 bold}}
console eval {wm geometry . 40x20}
console eval {. configure -background orange -highlightcolor brown -relief raised -border 30}
linershell         ```

## Change Log Section

gold 10/25/2020. Added box outline to calculator display. Added current 8.6 changes on local copy as suggestions to bare bones code. gold 10/26/2020. Added section 5 on button code from Line Calculator Namespace.