# load AGNI extension catch { if { $tcl_platform(platform) != "unix" } { load $env(AGNI_HOME)/lib/libetcl.dll Etcl } else { load $env(AGNI_HOME)/lib/libetcl.so Etcl } } error_string if { [string first "couldn't load file" $error_string] != -1 } { tk_messageBox -icon error -type ok -message $error_string exit } # join your favorite session join_session $env(AGNI_LOCAL) # This procedure : # 1- Sends a note to the /tutorial/note stream # 2- Destroys the GUI proc send {} { global .f2.t2 # get the note from the writer set note [.f2.t2 get 0.1 end] # open a connection with /tutorial/note stream_open /tutorial/note # send the note to /tutorial/note stream_append /tutorial/note $note exit } # This procedure displays all the previous notes proc display {note} { global .f1.t1 # enabled the writing in the t1 widget .f1.t1 configure -state normal # get rid the parentheses set note [lindex $note 0] # insert the previous notes .f1.t1 insert end $note # disabled the writing .f1.t1 configure -state disabled # move the end of t1 to see the last notes .f1.t1 see end } # This procedure kill the stream /tutorial/note, its agents and the GUI proc quit {} { # open a connection with /tutorial/note stream_open /tutorial/note # kill /tutorial/note stream_destroy /tutorial/note # destroy the GUI exit } # build the GUI frame .f1 text .f1.t1 -state disabled -yscrollcommand [list .f1.s set] -height 10 scrollbar .f1.s -command {.f1.t1 yview} -orient vertical frame .f2 label .f2.l -text "Please, enter your text here:" text .f2.t2 -height 7 frame .f3 button .f3.b1 -text "Send note..." -command {send} button .f3.b2 -text "exit..." -command {quit} pack .f1 .f2 .f3 -side top -fill both -expand 1 pack .f1.t1 -side left -fill both -expand 1 pack .f1.s -side left -fill y pack .f2.l -side top -fill both -expand 1 pack .f2.t2 -side top -fill both -expand 1 pack .f3.b1 -side left pack .f3.b2 -side left # display notes display $argv