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 and date in your comment with the same courtesy that I will give you. Aside from your courtesy, your wiki MONIKER and date as a signature and minimal good faith of any internet post are the rules of this TCL-WIKI. Its very hard to reply reasonably without some background of the correspondent on his WIKI bio page. Thanks, gold 12Dec2018
goldStarted roughly 2011-05-18. Here is an eTCL script on Call Procedure Fortran like. A call statement has some advantages in both Fortran and TCL languages. In some of the Fortran language versions, the call statement was used to call subroutines. For example, a call exit could be used to halt the program execution. For TCL, a call procedure can be developed that does not have to use brackets. The call statement is used to organize programs into a list of subroutines and to exit the program. Exiting a program was not a trivial function in the early days of programming. So a statement like "call exit" seemed pretty swank. Below, a generic TCL program passes control through various dummy procedures. Some "puts bye " and math statements are used to show control is passing through the procedures.
gold 12Dec2018. I have been informed that an advanced TCL user has added and checked this Call Exit subroutine into his homebrew TCL interpreter on his local copy of TCL on a PC system. I have added this subroutine code to my local TCL copy <meaning the source code library TCLLIB>, but I am not sure this routine adds much to what is already available on TCL.
gold 05Oct2020. A console program was added for experiment on Natural Language, if the King's English is a natural language. The console program was based on the antique program King Hamurabi.bas, ref Game kingdom of strategy. The idea was a limited set of input commands in the King's English, SVO as subject verb object. The initial commands in the computer game were King buy 30 or King sell 20.
console show proc call {args} {uplevel catch [list $args]} call initilize ;# list variables call subroutine1 call subroutine2 call subroutine3 call subroutine4 call exit ;# stop statement proc initilize return proc subroutine1 return proc subroutine2 return proc subroutine3 return proc subroutine4 call math sin(.5) return ... pseudocode:
# autoindent syntax from ased editor. # call procedure like fortran example # written on Windows XP on eTCL # working under TCL version 8.5.6 and eTCL 1.0.1 package require Tk console show proc call {args} {uplevel catch [list $args]} proc math { args } { set tcl_precision 17; puts [ expr [ expr { $args } ] ] } proc initilize {aa} { puts "subroutine initilize active" return } proc subroutine1 {aa} { puts "subroutine 1 active" return } proc subroutine2 {aa} { puts "subroutine 2 active" return } proc subroutine3 {aa} { puts "subroutine 3 active" return } proc subroutine4 {aa} { puts "subroutine 4 active" call math sin (.5) if { 1 == 1 } { puts "bye" } if { 1 == 2 } { call exit } return } call initilize ;# list variables call subroutine1 1 call subroutine2 2 call subroutine3 3 call subroutine4 4 call math sin (.5) if { 1 == 1 } { puts "bye bye" } % console output 0.479425538604203 bye 0.479425538604203 bye bye
console show proc pie {} {expr acos(-1)} proc writer {args } { puts $args } proc call {args} {uplevel catch [list $args]} call writer "jack" "&" "jill" call writer jack & jill went up the hill with [pie]
% console output jack & jill jack & jill went up the hill with 3.141592653589793
console show proc pie {} {expr acos(-1)} proc writer {args } { puts $args } proc math { args } { set tcl_precision 17; puts [ expr [ expr { $args } ] ] } proc mathx { args } { set tcl_precision 17; return [ expr [ expr { $args } ] ] } proc call {args} {uplevel catch [list $args]} call math 5 + 5 call math 5 + 5 call math sin (.5) set ccc [ mathx sin (.5) ] puts " value $ccc "
% console output 10 10 0.479425538604203 value 0.479425538604203
#ref. func proc from http://wiki.tcl.tk/14006 #Tacit programming #Tacit programming.mht,RS console show proc pie {} {expr acos(-1)} set aa 1 proc call {args} {uplevel catch [list $args]} proc math { args } { set tcl_precision 17; puts [ expr [ expr { $args } ] ] } proc func {name argl body} {proc $name $argl [list expr $body]} func atand aa (180./[pie])*atan($aa) puts " [atand 1. ] " console show proc pie {} {expr acos(-1)} set aa 1 proc call {args} {uplevel catch [list $args]} proc math { args } { set tcl_precision 17; puts [ expr [ expr { $args } ] ] } proc func {name argl body} {proc $name $argl [list expr $body]} func atand aa (180./[pie])*atan($aa) set aaa [ atand 1. ] puts $aaa #end of deck
output from console with program loaded, gold
1% call subroutine2 call subroutine 2 active6 % call 0 7% call call 0 8% call call call 0 #trivial (zero list) but no errors from multiple calls.
# pretty print autoindent from ased editor # trial console operation # Natural Language if King's English V2 # based on Hamurabi.bas antique game # written on Windows 10 on TCL # working under TCL version 8.6 # gold on TCL WIKI , 05ct2020 # pretty print from autoindent and ased editor # console has large black type on green # used as testbed for natural language # if the King's English is a natural language??? # written on Windows 10 on TCL # working under TCL version 8.6 # random list proc written by RS # added cosmetics and extensions # gold on TCL Club , 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 proc ? L { lindex $L [expr {int(rand()*[llength $L])}] #RS } if 0 {This is used several times in:} proc tidings {} { set a { {70 liters of grains} {20 liters of grain} {10 liters of grain} {10 liters of grain} {50 liters of grain} } set b { {400 hectares of land} {60 hectares of land} {50 hectares of land} {100 hectares of land} {20 hectares of land} } set c {rain dry heat cold drought snow } set d { {census 1000} {census 3000} {census 2000} {census 5000} {census 8000} {census 4000} } return " need [? $a]. need [? $b]. predict [? $c]. subjects from [? $d]. \n" } set sumit 1000 proc advisorx {aa bb} { puts " " puts "advisor: new situation " puts [ tidings ] puts "advisor: buy or sell, my lord? " } proc king { aa bb } { global sumit if { $aa == "buy" } {set token [ expr { 1.* $bb } ] } if { $aa == "sell" } {set token [ expr { -1.* $bb } ] } set sumit [ expr { $sumit + $token } ] puts " decision was $aa $bb, total was $sumit " advisorx 50 50 } # load initial pass for situation puts [ tidings ] puts "buy or sell, my lord? " puts " starts with 1000 units " puts "answer has form: king buy 20 or king sell 30 " 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}
gold This page is copyrighted under the TCL/TK license terms, this license .
Category Numerical Analysis | Category Toys | Category Calculator | Category Mathematics | Category Example | Toys and Games | Category Games | Category Application | Category GUI |