' this script needs trigger channel and then looks for every xth trigger ' where it fits an single expnential function between Cursor2 and 3. ' it write the timeconstant to the logfile and copies it to clipboard var a,b,c,d,e,f,g,h, tau, kanal, trigchan, startx, endx,mainwin%,log%,yes$,logfilename$; kanal:=input("what channel for fitting?",2); 'Channel to do the fit trigchan:=input("triggerchannel number?",401); 'triggerchannel Cursordelete(-1); 'delete all Cursors Cursornew(); 'make new Cursor1 interact("set Cursor1 in front of trigger", 1023); e:=nexttime(trigchan,Cursor(1)); 'e holds trigger time Cursor(1,e); 'set Cursor to triggertime Cursornew(); 'make Cursor 2 and 3 Cursornew(); interact("set Cursor2 and 3 to start and end of fitting range",1023); b:=Cursor(3)-Cursor(2); 'b gives range for fitting data startx:=Cursor(2)-e; ' start gives time after trigger (when to start the fit) endx:=startx+b; 'start gives time after trigger (when to end the fit) c:=input("how many trigger events to ignore?",11); 'look at every xth trigger only f:=input("how many fits should be made?",10); ' how many fits should be made 'delete logfile mainwin%:=View(); log%:=LogHandle(); 'get the logfile handle View(log%); 'go to logfile editselectall(); editclear(); View(mainwin%); 'and back to main window g:=g+1; 'g counts how many fits there are Chanfit(kanal,a,Cursor(2),Cursor(3)); ' do fit ChanFitShow(kanal,1); ' show it tau:=Chanfitcoef(kanal,1); 'get timeconstant ' if fit failes stop script if tau=0 then message("FIT FAILED!"); halt; endif; message(tau); 'show timeconstant 'and write to file Printlog("Fitnummer ", g, " Zeit im File: ",e," zeitkonstante ",tau); Printlog("\n");Printlog("\n");Printlog("\n");Printlog("\n");Printlog("\n");Printlog("\n");Printlog("\n");Printlog("\n");Printlog("\n");Printlog("\n");Printlog("\n"); ' do this g times REPEAT g:=g+1; for d:=1 to c do 'look for xth next trigger points and ignore them e:=nexttime(trigchan,e); if e<0 then halt; endif; next; Cursor(1,e); 'set Cursor 1 to next triggerevent that should be measured Cursor(2,e+startx); 'set Cursor 2 and 3 to adequate fit start and end times Cursor(3,e+endx); draw(Cursor(1)-0.1,startx+b+0.2); 'show fit 'Chanfit(kanal,1,1); Chanfit(kanal,a,Cursor(2),Cursor(3)); 'do fit ChanFitShow(kanal,1); tau:=Chanfitcoef(kanal,1); 'if fit failes stop script if tau=0 then message("FIT FAILED!"); halt; endif; 'write to logfile message(tau); Printlog("Fitnummer ", g, " Zeit im File: ",e," zeitkonstante ",tau); Printlog("\n");Printlog("\n");Printlog("\n");Printlog("\n");Printlog("\n");Printlog("\n");Printlog("\n");Printlog("\n");Printlog("\n");Printlog("\n");Printlog("\n"); UNTIL g=f; ' and save the file View(log%); ' show it editselectall(); editcopy(); yes$:=Input$("results were copied to clipboard, save file now? (y/n)","n",1); if yes$="y" then FileSaveAs(logfilename$,1); ' save it endif; View(mainwin%); 'and back to main window g:=0; a:=0;