Redirected from Tcl programming language
While Tcl itself does not provide an object oriented framework the language itself can be extended to provide new features as required. Indeed, many C extensions exist that provide OO functionality, including the powerful XOTcl[?] and more traditional incr Tcl. Some Tcl-based OO extensions also exist.
The most famous extension is the Tk toolkit which allows one to write portable graphical user interfaces for a variety of operating systems.
A simple example, demonstrating event-based computing, follows.
# Simple echo-server that can handle multiple connections. # This procedure is called when a client connects to the server proc newConnection {sock addr port} { fconfigure $sock -blocking no -buffering line # handleData should be called with $sock as the parameter when data can # be read from the socket fileevent $sock readable "handleData $sock" return } proc handleData {sock} { set line [gets $sock] if {($line == "") && [eof $sock]} { close $sock } else { puts $sock $line } return } socket -server newConnection 20000 vwait forever
proc every {ms body} { eval $body after $ms [list every $ms $body] } pack [label .clock -textvar time] every 1000 {set ::time [clock format [clock sec] -format %H:%M:%S]} ;# RS
Search Encyclopedia
|
Featured Article
|