On 15-Feb-2000 Ron Lawver - INA wrote:
> I'm really new to this visual tcl thing, but like it so far.
> What I'm trying to do (through vtcl) is to build a window with a button that
> when pushed
> will simply show the output of a tail command (example tail -100
> /var/adm/messages) into
> either that window, or another one. Any ideas?
> Thanks.
You need to place the resultant text into a text widget.
Assuming that the text widget is a child of the current toplevel window, you
should build a procedure to handle this.
Here's some example code that assumes that the textwidget's path is .txt:
proc file_reader {file_to_read numlines}
set fileid [open $file_to_read "r"]
set pass 1
#grab $numlines from the file, one line at a time
while { $pass <= $numlines} {
gets $fileid data
#insert the text into the text widget
.txt insert end $data
incr pass
}
close $fileid
}
**Note that this procedure reads from the beginning of the file, much like the
head command. I'll leave you to figure out how to get the tail effect, as I
don't want to simply hand you the code ;)
The procedure above would be invoked when the button '.b1' was pressed, and
would have to take care of passing $file_to_read and $numlines to file_reader.
In edit mode, double-click the button to edit the command performed when the
button is invoked.
Hope this helps.
---------------------------------------------------------------
Michael Avery <[EMAIL PROTECTED]>
Loran International Technologies
---------------------------------------------------------------
---------------------------------------------------------------------------
To unsubscribe from the Visual Tcl mailing list, please send a message
to [EMAIL PROTECTED] with "unsubscribe vtcl [EMAIL PROTECTED]" in the
message body (where [EMAIL PROTECTED] is your e-mail address).