Re: Interrupt Service Routines in Mathematica v.5.2?
- To: mathgroup at smc.vnet.net
- Subject: [mg73871] Re: Interrupt Service Routines in Mathematica v.5.2?
- From: David Bailey <dave at Remove_Thisdbailey.co.uk>
- Date: Fri, 2 Mar 2007 06:36:53 -0500 (EST)
- References: <es6d4i$ro8$1@smc.vnet.net>
Januk wrote: > Hi all, > > Is it possible to create an interrupt service routine in Mathematica v. > 5.2? While running a long calculation, I want to define some other > code that can be triggered by some event external to the calculation. > On completion of the interrupt service routine, the main calculation > should automatically resume with little or no knowledge that the > interrupt ever occurred. > > The first place I would like to use this would be to monitor a long, > complicated calculation in a loop. Each iteration through the loop > may be too slow (or too fast) for me to simply display diagnostic > information once per iteration. I would rather display the > information every x-seconds, or when the user presses a button. > > Any suggestions or comments would be appreciated. > > Thanks, > Januk > > Hello, The easiest way to do this is to use my Super Widget Package (available free from my site). After installing this, try: Needs["SuperWidgetPackage`"]; k=0; ff[x_]:=Print["k=",k]; {"Press for information",SuperWidgetButton[Null,"OK",ff]}//SuperGUIRun; While[True, k++; ] Each time you press the button, you will see the current value of k. Of course, you will have to kill the infinite loop in this trivial example by hand. David Bailey http://www.dbaileyconsultancy.co.uk