Function Browse4Folder(PathToFldr,CtrlName,PromptStr,CurrentFldr) // based on mg code from htdma toolkit String PathToFldr // path to data folder String PromptStr // Prompt text in data browser String CurrentFldr // current data folder String CtrlName variable exit=0 // stops trying when exit reaches 6 do string/g BrowserList string /g TempFldr=CurrentFldr variable/g Flag execute "CreateBrowser prompt=\""+PromptStr+"\", select=tempfldr" // prompt for file killstrings/z tempfldr svar BrowserList=s_browserlist nvar Flag=V_Flag // print browser_list if (!Flag) PathToFldr="cancelled" break endif if (itemsinlist(BrowserList)==1) if (stringmatch("root:ROOT;", BrowserList)) //data browser returns strange path if root is selected BrowserList="root" endif PathToFldr=stringfromlist(0,BrowserList)+":" if(DataFolderExists(PathToFldr)) break else doalert 0, "you must select a data folder, not a wave, string or variable! => try again" endif else doalert 0, "none or multiple data folders were selected => try again" endif exit+=1 while (exit<6) //maximum six attempts End #pragma rtGlobals=3 // Use modern global access method and strict wave access. Function LoadDateandtime() // Loads PAM data // Prompts to select folder into which data is loaded String PathToFldr="",CtrlName="",PromptStr="Select folder to load PAM time data into:",CurrentFldr=getdatafolder(1) // variables for Browse4Folder Browse4Folder(PathToFldr,CtrlName,PromptStr,CurrentFldr) // prompts user to select an experiment // Get folder with data in it NewPath/M="Select folder containing PAM time data:"/O/Q pathname // prompts user to select path to data folder PathInfo pathname // Abort if cancel is pressed If(V_flag==0) Abort "proceedure cancelled" EndIf // Make matrix for PAM data Make/o/n=(0,6) DateandTime // Strings and Variables Variable numfolders,n, subdirs, numfiles, filenum, refnum, thetime // variables String folderlist, filename, name, currentfolder, pathname,flag // strings // Counts number of files in folder NumFiles=ItemsInList(IndexedFile(pathname,-1,".txt")) // # files in folder , specify extensions e.g. ".txt" For(filenum=0;filenum10) // specify minimum file size to load e.g. >10bytes LoadPAMtimeFile() // Loads time wave taking into account AM/PM format *written by igorexchange Wave Temp_DateandTime0 wave temp_PAMdateTime // add loaded waves to loaded data InsertPoints DimSize(dateandtime,0),DimSize(Temp_dateandtime0,0), dateandtime dateandtime[DimSize(dateandtime,0)-DimSize(Temp_dateandtime0,0),*][]=Temp_dateandtime0[p-DimSize(dateandtime,0)+DimSize(Temp_dateandtime0,0)][q] currentfolder=GetDataFolder(1) // root folder for experiment Endif // end data to folder allocation EndIf EndFor // end loop through files of a dp Close/A // close open files Killwaves Temp_dateandtime0 // Do additional analytsis on PAM data ProcessPAM() // adds a time wave End Function Load_PAM_File(filename, refnum) // load single PAM file String filename Variable refnum String columnInfoStr String pathName // Name of an Igor symbolic path or "". columnInfoStr = "N=DateAndTime,F=8;" print "Loading: " + filename loadwave/v={"/: \t", "", 1,1}/q/a/n=Temp_PAMDataMatrix/m/o/j/k=1/l={0,0,0,7,0} filename // loads PAM data as a matrix End Menu "Load Waves" "Load PAM File...", Load_PAM_File("", "") End //Function LoadPAMFile(pathName, fileName) // This load function is used to specifically deal with time formats in AM/PM formats Function LoadPAMtimeFile() // This load function is used to specifically deal with time formats in AM/PM formats String PathToFldr="",CtrlName="",PromptStr="Select folder to load PAM data into:",CurrentFldr=getdatafolder(1) // variables for Browse4Folder Browse4Folder(PathToFldr,CtrlName,PromptStr,CurrentFldr) // prompts user to select an experiment // Get folder with data in it NewPath/M="Select folder containing PAM data:"/O/Q pathname // prompts user to select path to data folder PathInfo pathname // Abort if cancel is pressed If(V_flag==0) Abort "proceedure cancelled" EndIf // Strings and Variables Variable numfolders,n, subdirs, numfiles, filenum, refnum, thetime // variables String folderlist, filename, name, currentfolder, pathname,flag // strings // Counts number of files in folder NumFiles=ItemsInList(IndexedFile(pathname,-1,".txt")) // # files in folder , specify extensions e.g. ".txt" For(filenum=0;filenum= secondsIn12Hours) adjustment = -secondsIn12Hours endif else // PM: Adds 12 hours unless hour is 12:xx. if (theTime < secondsIn12Hours) adjustment = secondsIn12Hours endif endif return adjustment End Function ProcessPAM() // Additional processing of PAM data Wave PAMDataMatrix Make/o/d/n=(DimSize(PAMDataMatrix,0)) PAMTime SetScale d,0,0,"dat" PAMTime PAMTime=Date2Secs(PAMDataMatrix[p][2],PAMDataMatrix[p][0],PAMDataMatrix[p][1])+PAMDataMatrix[p][3]*3600+PAMDataMatrix[p][4]*60+PAMDataMatrix[P][5] End