Re: timer
- To: mathgroup at smc.vnet.net
- Subject: [mg63467] Re: [mg63440] timer
- From: Christopher Purcell <christopherpurcell at mac.com>
- Date: Sun, 1 Jan 2006 01:16:32 -0500 (EST)
- References: <200512311140.GAA28059@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
(* The JLink documentation in Version 5.2 describes the routine AddPeriodical which may be a starting point for your timer. To test this I loaded the WebServices package to make a little routine that gets a stock quote every 60 seconds and appends it to a text file called "ticker.txt". Note that the kernel is not tied up while waiting the 60 seconds, you can carry on working. *) Needs["JLink`"]; Needs["WebServices`"]; InstallService["http://www.webservicex.com/stockquote.asmx?WSDL"]; writequote[symb_String]:=Module[{quote,last},( quote=GetQuote[symb]; last=ToExpression[StringTake[quote,{1+Last[StringPosition [quote,"<Last>"][[1]]],-1+First[StringPosition[quote,"</Last>"] [[1]]]}]]; last>>>ticker.txt)] task=AddPeriodical[writequote["AAPL"],60]; (* start the JLink timer and get its id, we are looking up Apple Computer's stock price every 60 seconds *) (* After this runs for a bit you can list the file and see the stock prices. *) !!ticker.txt 71.89 71.89 71.89 (* the markets were closed when I did this, so no changes are visible *) RemovePeriodical[task]; (* to shut down the timer process *) (* You should just have to substitute your expression to be evaluated for the "writequote" function. Note the JLink documentation says AddPeriodical won't write to a notebook, so that's why I sent the results out to an external file. *) christopherpurcell at mac.com On Dec 31, 2005, at 7:40 AM, ekantian wrote: > i would like to be able to have a cell evaluated automatically at a > specified time (say, 10:00 pm when i'm away from my computer). you see > i always forget to start my lengthy methematica processes before > end of > day. would prefer to do this from within mathematica notebook (rather > than with windows batch file & m code). i do assume the notebook > would > have to be already open for any such process to work. is there a way? > > please post any suggestions. thx. >