# $Header: /home/cvsroot/tcldb/ucodb/Tlib/saveText,v 1.2 1998/03/14 08:17:57 de Exp $
# tcl procs saved on Sun Sep 03 16:19:11 PDT 1995

proc saveText {box filename} {

	set unique [getclock]

	set win .[lindex [split $box .] 1]
	set wlist [winfo children $win]
	$win configure -cursor watch
	foreach child $wlist {
		$child configure -cursor watch
	}

	set of "$filename.$unique"
	set err [catch {set ofp [open $of w]}]
	if {$err} {
		set of "/tmp/$filename.$unique"	
		set ofp [open $of w]
	}

	set err [catch {set len [$box size]} res]

	if {!$err} {
	loop i 0 $len {
		puts $ofp "[stringFix2 [$box get $i] out]"
	}
	} else {
		set text "[$box get 1.0 end]"
		puts $ofp "$text"
	}

	close $ofp

	$win configure -cursor {}
	foreach child $wlist {
		$child configure -cursor {}
	}
	echo "Output is in file $of"
}

