Hi Sean,
you could write a procedure which checks stdio of the C program, inserts
it into the text widget and schedules itself again using the 'after�
command:
proc checkOutput {} {
global exec
while { [gets $exec data] >= 0} {
.top26.tex30 insert end "$data\n"
}
after 100 checkOutput
}
If you call that proc once, it will call itself every 100 millisecs
recursively. `update' is not necessary. You probably need to configure
the input stream to non-blocking mode:
fconfigure $exec -blocking 0
Regards
Martin
Sean Billings wrote:
>
> Hello,
>
> I am trying to use Vtcl to produce an X front end for
> a commandline program written in C. All it has to do
> is exec the program when it is run display all output
> onto a text widget and then kill the app when the
> exit button is pressed.
>
> I am using the below code to execute and capture the
> stdio output which works well, except that you cannot
> use the exit button while it is running. What I need
> to know is if there is an equivalent function similar
> to Visual Basic's DoEvents()? ie, allow the script to
> multitask properly, or is there another approach to
> this?
>
> .top26.tex30 delete 1.0 end
>
> set exec [ open |$script r ]
> while { [gets $exec data] >= 0} {
> update
> .top26.tex30 insert end "$data\n"
> update
> }
> close $exec
>
> 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).
---------------------------------------------------------------------------
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).