#pragma rtGlobals=3 // Use modern global access method. #pragma DefaultTab={3,20,4} // Set default tab width in Igor Pro 9 and later Function load_DLS_ALV_New() GetFileFolderInfo/D /Q // open file dialog if (V_Flag != 0) // user canceled or some other error return 0 endif newpath/O/Q cgms S_path string filelist= IndexedFile(cgms,-1,".asc") if (WinType("ResultGraph0") == 1) // if graphs already exist => kill (or abort if you want) KillWindow ResultGraph0 endif if (WinType("ResultGraph1") == 1) KillWindow ResultGraph1 endif Display/W=(0,0,340,280)/N=ResultGraph0; Display/W=(440,0,780,280)/N=ResultGraph1; variable i for (i = 0; i < ItemsInList(filelist); i += 1) // rather use for loops unless do-while loop is really beneficial string fname = StringFromList(i,filelist) // process list of files LoadWave/Q/J/D/A=wLoaded/P=cgms/K=0/ENCG=3 /L={0,27,231,0,1} fname // first: load the data LoadWave/Q/J/D/A=wLoaded/P=cgms/K=0/ENCG=3 /L={0,27,231,1,1} fname // the /Q flag prevents printing into the history LoadWave/Q/J/D/A=wLoaded/P=cgms/K=0/ENCG=3 /L={0,14,10,1,1} fname // I used the /ENCG flag to define the file encoding (prevents tedious dialogues) // you might want to add a check for success of loading operation Wave wLoaded0 // second: local (code) reference to loaded data (assumes everything worked as expected) Wave wLoaded1 // needs to be done after loading, since otherwise you point to nothing Wave wLoaded2 string basename = RemoveEnding(fname,".asc") // remove file ending => base for wave naming string wnameTau = basename+"_Tau" string wnameIACF = basename+"_IACF" string wnameParam = basename+"_Param" string wnameEACF = basename+"_EACF" //Calculate EACFs Duplicate/O wLoaded1 $wnameEACF Wave calcWave = $wnameEACF // again, local reference to existing wave calcWave /= mean(wLoaded1,20,40) // do calculation Duplicate/O wLoaded0, $wnameTau // third: 'renaming' => rather use Duplicate + KillWaves, since Rename fails if target wave already exists Duplicate/O wLoaded1, $wnameIACF Duplicate/O wLoaded2, $wnameParam KillWaves wLoaded0, wLoaded1, wLoaded2 AppendToGraph/W=ResultGraph0 $wnameIACF vs $wnameTau AppendToGraph/W=ResultGraph1 $wnameEACF vs $wnameTau endfor DoWindow/F ResultGraph0 // fourth: apply layout to both graphs Execute "MyGraphStyle()" Label/W=ResultGraph0/Z left "\\Z16 IACF" DoWindow/F ResultGraph1 Execute "MyGraphStyle()" Label/W=ResultGraph1/Z left "\\Z16 ISF" return 0 End Proc MyGraphStyle() : GraphStyle // just have one style which you can apply to all graphs PauseUpdate; Silent 1 ModifyGraph/Z log(bottom)=1 ModifyGraph/Z width=340,height=280 ModifyGraph/Z lSize=2 ModifyGraph/Z rgb[0]=(3,52428,1),rgb[1]=(0,0,0),rgb[2]=(1,16019,65535),rgb[4]=(65535,49157,16385) ModifyGraph/Z rgb[5]=(0,43690,65535),rgb[6]=(65535,16385,55749),rgb[7]=(1,39321,39321) ModifyGraph/Z rgb[8]=(39321,26208,1),rgb[9]=(2,39321,1),rgb[10]=(65535,65532,16385) ModifyGraph/Z rgb[11]=(36873,14755,58982) ModifyGraph/Z tick=2 ModifyGraph/Z zero(left)=0 ModifyGraph/Z mirror=1 ModifyGraph/Z minor=1 ModifyGraph/Z sep=10 ModifyGraph/Z fSize=14 ModifyGraph/Z lblMargin(left)=18 ModifyGraph/Z axThick=1.5 ModifyGraph/Z gridRGB(left)=(21845,21845,21845) ModifyGraph/Z notation(left)=1 ModifyGraph/Z gridHair(left)=1 ModifyGraph/Z lblLatPos(left)=-12 Label/Z bottom "\\Z16 Delay time [ms]" Legend/C/N=text0/F=0/A=LB // left-bottom alignment ModifyGraph/Z btLen=4 End