1<HTML><HEAD><TITLE>Tcl Built-In Commands - update manual page</TITLE></HEAD><BODY> 2<H3><A NAME="M2">NAME</A></H3> 3update - Process pending events and idle callbacks 4<H3><A NAME="M3">SYNOPSIS</A></H3> 5<B>update</B> ?<B>idletasks</B>?<BR> 6<H3><A NAME="M4">DESCRIPTION</A></H3> 7This command is used to bring the application ``up to date'' 8by entering the event loop repeatedly until all pending events 9(including idle callbacks) have been processed. 10<P> 11If the <B>idletasks</B> keyword is specified as an argument to the 12command, then no new events or errors are processed; only idle 13callbacks are invoked. 14This causes operations that are normally deferred, such as display 15updates and window layout calculations, to be performed immediately. 16<P> 17The <B>update idletasks</B> command is useful in scripts where 18changes have been made to the application's state and you want those 19changes to appear on the display immediately, rather than waiting 20for the script to complete. Most display updates are performed as 21idle callbacks, so <B>update idletasks</B> will cause them to run. 22However, there are some kinds of updates that only happen in 23response to events, such as those triggered by window size changes; 24these updates will not occur in <B>update idletasks</B>. 25<P> 26The <B>update</B> command with no options is useful in scripts where 27you are performing a long-running computation but you still want 28the application to respond to events such as user interactions; if 29you occasionally call <B>update</B> then user input will be processed 30during the next call to <B>update</B>. 31<H3><A NAME="M5">EXAMPLE</A></H3> 32Run computations for about a second and then finish: 33<PRE>set x 1000 34set done 0 35after 1000 set done 1 36while {!$done} { 37 # A very silly example! 38 set x [expr {log($x) ** 2.8}] 39 40 # Test to see if our time-limit has been hit. This would 41 # also give a chance for serving network sockets and, if 42 # the Tk package is loaded, updating a user interface. 43 <B>update</B> 44}</PRE> 45<H3><A NAME="M6">SEE ALSO</A></H3> 46<B><A HREF="../TclCmd/after.htm">after</A></B>, <B><A HREF="../TclCmd/bgerror.htm">bgerror</A></B> 47<H3><A NAME="M7">KEYWORDS</A></H3> 48<A href="../Keywords/E.htm#event">event</A>, <A href="../Keywords/F.htm#flush">flush</A>, <A href="../Keywords/H.htm#handler">handler</A>, <A href="../Keywords/I.htm#idle">idle</A>, <A href="../Keywords/U.htm#update">update</A> 49<HR><PRE> 50<A HREF="../copyright.htm">Copyright</A> © 1990-1992 The Regents of the University of California. 51<A HREF="../copyright.htm">Copyright</A> © 1994-1996 Sun Microsystems, Inc. 52<A HREF="../copyright.htm">Copyright</A> © 1995-1997 Roger E. Critchlow Jr.</PRE> 53</BODY></HTML> 54