Hello,
Thanks for the help guys :-) I have attached the new
working version of the function for anyone that is
interested.:
to initiate I use the following
+++++++++++++++++
# start up the Nserver engine
global Nserver_PID
set PipeHandle [open "|nserver -gui"]
# Set to non-blocking
fconfigure $PipeHandle -blocking 0
# Grab the PID
set Nserver_PID [pid $PipeHandle]
# and setup the stdio capture
fileevent $PipeHandle readable [list read_pipe $PipeHandle]
+++++++++++++++++
----------------
Function: read_pipe
Arguments: PipeHandle
# Read one line from the Pipe
global Recurse
catch {
if {[string compare $Recurse True]==0} then {
return
}
}
set Recurse True
if [eof $PipeHandle] {
catch {close $PipeHandle}
return
}
gets $PipeHandle data
if {[string compare $data *\[up\]*]==0} {
set pos [.top26.tex30 index end]
set pos [.top26.tex30 index "$pos -1 lines"]
.top26.tex30 delete "$pos linestart" end
return
}
.top26.tex30 insert end "\n$data"
.top26.tex30 see end
update
update idletasks
set Recurse False
----------------
I will just explain some of the quirky bits:
If the C application outputs *[up]* via stdio
then this tells my app to delete the last line
effectively moving back up.
The global Recurse var prevents the function
being called while it is still processing,
without it it was possible for some lines to
appear in the window in the wrong order.
Regards Sean.
---------------------------------------------------------------------------
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).