This page is under development. Comments are welcome, but please load any comments in the comments section at the bottom of the page. Please sign your user-name with the same courtesy that I will give you. Thanks,gold
gold 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.
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.
gold This page is copyrighted under the TCL/TK license terms, this license .
Please place any comments here, Thanks.
Category Numerical Analysis | Category Toys | Category Calculator | Category Mathematics | Category Example | Toys and Games | Category Games | Category Application | Category GUI |