#!/usr/local/bin/wish4.2
	# Questioners often ask in comp.lang.tcl, "how can I tail
	#     a file into a widget ...?"  This is a minimal answer.
	
	
	
	
	proc begin_tail_process {filename widget} {
			# There's no provision here for an unreadable $filename.
		set fd [open "|tail -f $filename" r]
		fconfigure $fd -blocking no
		fileevent $fd readable "process_one_line $fd $widget"
	}
	
	
	proc handle_command_arguments {} {
		global argc argv
	
		if {1 != $argc} {
			puts "The syntax is 'experiment FILENAME'."
			exit 1
		}
		return [lindex $argv 0]
	}
	
	
	########
	#
	#	process_one_line
	#
	#	Notice that there's no exception-handling ($filename
	#	     becomes unreadable, ...)
	#
	########
	proc process_one_line {fd widget} {
		gets $fd line
			# Put the new tail-ed line at the bottom of
			#     the display.
		$widget insert end "$line\n"
			# Ensure that the last line is visible.
		$widget yview -pickplace end
	}
	
	
	proc setup_display_widget text_widget {
		text $text_widget
		pack $text_widget
	}
	
	###############################################################
	set file [handle_command_arguments]
	set widget .my_text_widget
	
	setup_display_widget $widget
	begin_tail_process $file $widget