**Sumerian Base 60 conversion and eTCL demo example calculator, numerical analysis ** 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 Sumerian Base 60 conversion. Loaded [RS] routines from [base conversion] into a slot calculator shell. ---- ***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 **** %|table 1|printed in| tcl wiki format|% &| quantity| value| comment, if any|& &| 1:|testcase_number | |& &| 101.0 :|number n| |& &| 60.0 :|optional base 60? | |& &| 1.0 :|optional logic switch (1,2,3?) | |& &| 1.0 :|optional | |& &| 1.0 :|optional | |& &| 1.0 :|optional | |& &| 141 :|base 60 | |& &| 3601 :|base 60 | |& &| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 :|list other base symbols | |& **** Testcase 2 **** %|table 2|printed in| tcl wiki format|% &| quantity| value| comment, if any|& &| 2:|testcase_number | |& &| 30.0 :|number n| |& &| 60.0 :|optional base 60? | |& &| 1.0 :|optional logic switch (1,2,3?) | |& &| 1.0 :|optional | |& &| 1.0 :|optional | |& &| 1.0 :|optional | |& &| 30 :|base 60 | |& &| 180 :|base 60 | |& &| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 :|list other base symbols | |& **** Testcase 3 **** %|table 3|printed in| tcl wiki format|% &| quantity| value| comment, if any|& &| 3:|testcase_number | |& &| 90.0 :|number n| |& &| 60.0 :|optional base 60? | |& &| 1.0 :|optional logic switch (1,2,3?) | |& &| 1.0 :|optional | |& &| 1.0 :|optional | |& &| 1.0 :|optional | |& &| 130 :|base 60 | |& &| 540 :|base 60 | |& &| 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 :|list other base symbols | |& ---- ***Screenshots Section*** ****figure 1.**** [Sumerian Base 60 conversion and eTCL demo example screenshot] ---- ***References:*** * [A base-5 clock] * [Abstract base classes with TclOO] * [base 8 number] * [Base 64 encode/decode] * [base 64 encoding (Garrigues)] * [base conversion] * [base-svc-thread] * [base-tcl] * [base-tcl-thread] * [base-tclsvc-thread] * [base-tk] * [Oneliner's Pie in the Sky] * [One Liners] * [A little slide-rule] * [What if you do not have exp()?] * [Category Algorithm] ---- **Appendix Code** ***appendix TCL programs and scripts *** ====== # pretty print from autoindent and ased editor # Base 60 Conversion # written on Windows XP on eTCL # working under TCL version 8.5.6 and eTCL 1.0.1 # gold on TCL WIKI, 15jan2017 package require Tk package require math::numtheory namespace path {::tcl::mathop ::tcl::mathfunc math::numtheory } set tcl_precision 17 frame .frame -relief flat -bg aquamarine4 pack .frame -side top -fill y -anchor center set names {{} {number $n :} } lappend names {optional base 60?:} lappend names {optional logic switch (1,2,3?): } lappend names {optional: } lappend names {optional:} lappend names {optional: } lappend names {to base : } lappend names {from base :} foreach i {1 2 3 4 5 6 7 8} { label .frame.label$i -text [lindex $names $i] -anchor e entry .frame.entry$i -width 35 -textvariable side$i grid .frame.label$i .frame.entry$i -sticky ew -pady 2 -padx 1 } proc about {} { set msg "Calculator for Base 60 Conversion from TCL WIKI, written on eTCL " tk_messageBox -title "About" -message $msg } proc list_base_numbers { aa bb} { for {set i 0} {$i<=$bb} {incr i} {lappend list_n [ int $i] };return $list_n} proc base {base number} { global side1 side2 side3 side4 side5 global side6 side7 side8 digits5 set negative [regexp ^-(.+) $number -> number] ;# (1) set digits $digits5 set res {} while {$number} { set digit [expr {$number % $base}] set res [lindex $digits $digit]$res set number [expr {$number / $base}] } if $negative {set res -$res} set res } proc frombase {base number} { global side1 side2 side3 side4 side5 global side6 side7 side8 digits5 set digits $digits5 set negative [regexp ^-(.+) $number -> number] set res 0 foreach digit [split $number ""] { set decimalvalue [lsearch $digits $digit] if {$decimalvalue<0 || $decimalvalue >= $base} { error "bad digit $decimalvalue for base $base" } set res [expr {$res*$base + $decimalvalue}] } if $negative {set res -$res} set res } proc calculate { } { global answer2 global side1 side2 side3 side4 side5 global side6 side7 side8 global testcase_number digits5 incr testcase_number set side1 [* $side1 1. ] set side2 [* $side2 1. ] set side3 [* $side3 1. ] set side4 [* $side4 1. ] set side5 [* $side5 1. ] set side6 [* $side6 1. ] set side7 [* $side7 1. ] set side8 [* $side8 1. ] #set digits { [ list_numbers 0 $base ] } set digits_fixed_symbols {0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60} set digits_alfa_numbers {0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z} set base [int $side2 ] set digits5 [ list_base_numbers 0 $base ] if {$side3 > 1. } { set digits5 $digits_alfa_numbers } if {$side3 > 2. } { set digits5 $digits_fixed_symbols } set side7 [ base $base [int $side1 ] ] set side8 [ frombase $base [ int $side1 ] ] } proc fillup {aa bb cc dd ee ff gg hh} { .frame.entry1 insert 0 "$aa" .frame.entry2 insert 0 "$bb" .frame.entry3 insert 0 "$cc" .frame.entry4 insert 0 "$dd" .frame.entry5 insert 0 "$ee" .frame.entry6 insert 0 "$ff" .frame.entry7 insert 0 "$gg" .frame.entry8 insert 0 "$hh" } proc clearx {} { foreach i {1 2 3 4 5 6 7 8 } { .frame.entry$i delete 0 end } } proc reportx {} { global side1 side2 side3 side4 side5 global side6 side7 side8 global testcase_number digits5 console show; puts "%|table $testcase_number|printed in| tcl wiki format|% " puts "&| quantity| value| comment, if any|& " puts "&| $testcase_number:|testcase_number | |&" puts "&| $side1 :|number n| |&" puts "&| $side2 :|optional base 60? | |& " puts "&| $side3 :|optional logic switch (1,2,3?) | |& " puts "&| $side4 :|optional | |&" puts "&| $side5 :|optional | |&" puts "&| $side6 :|optional | |&" puts "&| $side7 :|base 60 | |&" puts "&| $side8 :|base 60 | |&" puts "&| $digits5 :|list other base symbols | |&" } frame .buttons -bg aquamarine4 ::ttk::button .calculator -text "Solve" -command { calculate } ::ttk::button .test2 -text "Testcase1" -command {clearx;fillup 101.0 60. 1.0 1.0 1.0 1. 141. 3601.} ::ttk::button .test3 -text "Testcase2" -command {clearx;fillup 30.0 60.0 1.0 1.0 1.0 1. 30. 180. } ::ttk::button .test4 -text "Testcase3" -command {clearx;fillup 90.0 60. 1.0 1.0 1.0 1. 130. 540. } ::ttk::button .clearallx -text clear -command {clearx } ::ttk::button .about -text about -command {about} ::ttk::button .cons -text report -command { reportx } ::ttk::button .exit -text exit -command {exit} pack .calculator -in .buttons -side top -padx 10 -pady 5 pack .clearallx .cons .about .exit .test4 .test3 .test2 -side bottom -in .buttons grid .frame .buttons -sticky ns -pady {0 10} . configure -background aquamarine4 -highlightcolor brown -relief raised -border 30 wm title . "Base 60 Conversion Calculator" ====== ---- *** Pushbutton Operation*** For the push buttons, the recommended procedure is push testcase and fill frame, change first three entries etc, push solve, and then push report. Report allows copy and paste from console. For testcases in a computer session, the eTCL calculator increments a new testcase number internally, eg. TC(1), TC(2) , TC(3) , TC(N). The testcase number is internal to the calculator and will not be printed until the report button is pushed for the current result numbers. The current result numbers will be cleared on the next solve button. The command { calculate; reportx } or { calculate ; reportx; clearx } can be added or changed to report automatically. Another wrinkle would be to print out the current text, delimiters, and numbers in a TCL wiki style table as ====== puts " %| testcase $testcase_number | value| units |comment |%" puts " &| volume| $volume| cubic meters |based on length $side1 and width $side2 |&" ====== ---- [gold] This page is copyrighted under the TCL/TK license terms, [http://tcl.tk/software/tcltk/license.html%|%this license]. **Comments Section** <> Please place any comments here, Thanks. <> Numerical Analysis | Toys | Calculator | Mathematics| Example| Toys and Games | Games | Application | GUI