{ This macro captures slices at a time interval specified by the user. Shutter opens, waits 100msec. before grabbing first image.Each slice is the average of a number of frames also specified by the user. Each averaged frame is automatically saved to the disc as 'Name.001' . The first image 'Name.000' should be discarded. Pressing the mouse button should abort the macro. } macro 'Save averaged time-lapse to disk'; var nFrames,n,Left,Top,Width,Height:integer; choice,interval,EndTicks,secs:integer; year,month,day,hour,minute,second,dow,camera, stack, nAvg:integer; comment,filename: string; FirstTime:boolean; starttime, time:real; begin GetRoi(Left,Top,Width,Height); if width=0 then begin PutMessage('First select the area of interest in the Camera window.'); exit; end; SelectWindow('Camera'); camera:=PidNumber; nFrames:=GetNumber('Number of Frames?',100); secs:=GetNumber ('Delay Between Frames (seconds)?',4); interval:=round(secs*60); filename:=GetString ('Name of file?','Movie'); choice:=GetNumber ('Average (1) or integrate (2)?',1); nAvg:=GetNumber('Number of frames to average/integrate per slice:', 6); comment:=GetString('Comments?','none'); FirstTime:=true; SetNewSize(width,height); starttime:=TickCount; for n:=1 to nFrames do begin ChoosePic(Camera); MakeRoi(Left,Top,Width,Height); {OpenShutter;} Wait(.1); if choice=1 then AverageFrames('average',nAvg); if choice=2 then AverageFrames('integrate',nAvg); {CloseShutter;} SaveAs (filename'.', n-1:3); time:=(Tickcount-starttime)/60; RestoreRoi; if FirstTime then begin EndTicks:=TickCount+interval; FirstTime:=false; end; if button then begin exit; end; while TickCount