#pragma rtGlobals=3 // Use modern global access method and strict wave access. // none bugs // 5. Dynafit location setup! // 6. Add function to select graph to add the fit on! // 7. add function to select options to create new scripts file and keep or remove old data // 8. add save script file feature! // 9. Fix scriptfile name //13. dbl exp rate and i got this rate are not plotted by the program so how to handle the removal? Menu "DynafiHook" "Open DynafitScript", Dynafitpath("Tab") "Run Dynafit script", RunDynafit("Tab") "Update Param", Updateparam("Tab") end Function RunDynafit(ctrlname) string Ctrlname String scriptpath,Dynafitpath String Dynafit_Log, errmsg Variable errorlocation,len svar OS= OS updateconstants() writescriptfile() Wave/T var = Dynafit_var Wave/T val = Dynafit_value String cmd scriptpath = val[1] Dynafitpath = val[0] strswitch(OS) Case "Macintosh": sprintf cmd, "do shell script \"cd %s && ./DynaFitC %s \"" , Dynafitpath , scriptpath break case "Windows": dynafitpath =replacestring("\\", dynafitpath, "",1,1) Scriptpath =replacestring("\\", scriptpath, "",1,1) scriptpath = scriptpath[0,strlen(scriptpath)-3] Sprintf cmd, "cmd.exe /C cd %s & DynaFitC %s ", Dynafitpath , scriptpath Endswitch print cmd ExecuteScriptText cmd Dynafit_log = S_value errorlocation = strsearch (Dynafit_Log, "error:" , 0 ,2) if (errorlocation > -1) len = strlen(Dynafit_log) errmsg = Dynafit_log[errorlocation+6,len -2] errmsg = "Please check Script, got the following error: " + errmsg Abort errmsg endif Print S_value nvar plotcont = plotcont if (plotcont== 2) ClearPrevPlot() endif getdatafile() Dynafit_load() return 0 End //-------------------------------------------------------------------------------------------------------------------------------- Function ClearPrevPlot() svar basename = basename svar plotgraph = plotgraph nvar counter = counter nvar fittype = fittype variable i, noitems String wavelst , win, wavenm String tablename = basename+"_Table" + num2str(counter) Dowindow /F $plotgraph if (V_flag == 0) return 0 endif Dowindow /F $tablename if (V_flag == 1) win = "Win:" + tablename wavelst = wavelist("*", ";", win ) print wavelst noitems = itemsinlist(wavelst) win = "win:"+plotgraph for (i = 0 ; i< noitems ; i +=1) wavenm = stringfromlist(i , wavelst) if (strlen(wavelist(wavenm,";",win))) Print "Removing Last trace:" , wavenm removefromgraph/W = $plotgraph $wavenm endif removefromtable/W = $tablename $wavenm killwaves/Z $wavenm endfor killwindow $tablename else return 0 endif String Graphname = basename+"_Graph" + num2str(counter) Dowindow /F $Graphname if (V_flag == 1) win = "Win:" + graphname wavelst = tracenamelist(graphname, ";" , 0) print wavelst noitems = itemsinlist(wavelst) for (i = 0 ; i< noitems ; i +=1) wavenm = stringfromlist(i , wavelst) removefromgraph/W = $graphname $wavenm killwaves/Z $wavenm endfor killwindow $graphname else return 0 endif end //-------------------------------------------------------------------------------------------------------------------------------- Function/S DoOpenFileDialog() Variable refNum svar OS String message = "Select a file" String outputPath String fileFilters = "Data Files (*.txt,*.dat,*.csv):.txt,.dat,.csv;" fileFilters += "All Files:.*;" Open/R /F=fileFilters /M=message refNum if (refNum == 0) Return "False" // User canceled endif outputPath = S_fileName close refnum Print outputpath strswitch(os) case "Macintosh" : OutputPath = replacestring(":", outputPath, "/") OutputPath = replacestring("Macintosh HD/", outputPath, "/") //sprintf outputPath, "\\\"%s\\\"" , outputPath break case "Windows": //OutputPath = replacestring(":", outputPath, "\\") Outputpath = ParseFilePath(5, outputpath, "\\", 0, 0) endswitch sprintf outputPath, "\\\"%s\\\"" , outputPath return outputPath // Will be empty if user canceled End //-------------------------------------------------------------------------------------------------------------------------------- Function dynafitPath(ctrlname) :Buttoncontrol String Ctrlname String /G OS = igorinfo(2) String scriptfile = DoOpenFileDialog() if (Stringmatch(scriptfile, "False")==1) Print "Exiting because no file selected?" return -1 endif Variable Dynafitlocation Variable Scriptlocation String Dynafitpath String ScriptPath print scriptfile dynafitlocation = strsearch(scriptfile, "Dynafit", 0,2) print dynafitlocation if (dynafitlocation == -1 ) Abort "Please make sure the script file is within the dynafit folder" endif strswitch(os) case "Macintosh": scriptlocation = strsearch(scriptfile, "/" , dynafitlocation,0) break case "Windows": scriptlocation = strsearch(scriptfile, "\\" , dynafitlocation,0) endswitch Dynafitpath = scriptfile[0,scriptlocation-1] + "\\\"" print "Dynafit Loaction:" , Dynafitpath variable Len =strlen(scriptfile) ScriptPath = "\\\"" + scriptfile[scriptlocation+1, len] print "Script File Loaction:", ScriptPath Readscript (scriptfile) Make /T/O/N= 2 Dynafit_var, Dynafit_value Dynafit_var[0] = "Dynafit Location" Dynafit_value [0] = Dynafitpath Dynafit_var[1] = "ScriptFile Location" //Dynafit_value [1] = scriptpath parsescript() getconstants() Createpanel() end //-------------------------------------------------------------------------------------------------------------------------------- Function Readscript(scriptfile) String scriptfile String script = "" Svar OS =OS strswitch(os) case "Macintosh": scriptfile = replacestring("\"", scriptfile , "") scriptfile = replacestring("\\", scriptfile , "") scriptfile = replacestring("/", scriptfile , ":") scriptfile = "Macintosh HD" + scriptfile break case "Windows": scriptfile = replacestring("\"", scriptfile , "") scriptfile = replacestring("\\", scriptfile , "",1,2) scriptfile = replacestring ("\\", scriptfile ,":") scriptfile = replacestring (" ", scriptfile ,"") scriptfile = scriptfile[ 0, strlen(Scriptfile)-2] endswitch Variable refnum print"Opening Scriptfile:", scriptfile open /R refnum scriptfile Print "Scriptfile opened" Variable lineNumber, len String buffer lineNumber = 0 do FReadLine refNum, buffer len = strlen(buffer) if (len == 0) break // No more lines to be read endif script = script + buffer if (CmpStr(buffer[len-1],"\r") != 0) // Last line has no CR ? Printf "\r" endif lineNumber += 1 while (1) close refnum Dowindow DynaFitScript if (V_Flag == 0) NewNotebook /Z/N = DynaFitScript /F = 0/W=(900,400, 1250, 700) endif Notebook DynaFitScript selection={startOfFile, endOfFile} , text = script end //-------------------------------------------------------------------------------------------------------------------------------- Function Parsescript() Dowindow DynaFitScript if (V_flag == 0) Abort "Unable to Find Dynafit Notebook Window, Please Import script" endif Notebook DynaFitScript getData = 1 String script = S_value Variable DataheadLocation, Outputheadlocation variable simdirlocation, EOLlocation, wavepoint String simdatadirectory , simfileextension, Dynafitpath,cmd, igorscript Svar OS =OS wave/T var = Dynafit_var wave/T val = Dynafit_value If (Strsearch(script , "task = simulate", 0 , 2) > -1) // section to find directory of simulated data! Findvalue /Text = "SimOut Location" var if (V_value == -1) insertpoints numpnts(var), 1 , var,val wavepoint = numpnts(Var)-1 var[wavepoint] = "SimOut Location" else wavepoint = V_value endif //simdatadirectory = findparam(script, "directory", "data") String dynaloc = val[0] strswitch (os) case "Macintosh": dynaloc = replacestring("\\", dynaloc, "") dynaloc = replacestring("\"", dynaloc,"") dynaloc = "Macintosh HD" + dynaloc + "/IGOR_Dynadata" dynaloc = replacestring("/", dynaloc ,":") break case "Windows": dynaloc = replacestring("\\", dynaloc, "",1,2) dynaloc = replacestring("\"", dynaloc,"") dynaloc = replacestring("\\", dynaloc,":") dynaloc = dynaloc + "IGOR_Dynadata" endswitch if (replaceparam(script, "directory", "data", "./IGOR_Dynadata") == 1 ) val[wavepoint] = dynaloc Notebook DynaFitScript getData = 1 script = S_value Print "Output files to Igor_Dynadata dir" Findvalue /Text = "Dynafit Location" var Dynafitpath = val[V_value] strswitch(os) case "Macintosh": Dynafitpath = replacestring("\\", Dynafitpath , "") Dynafitpath = replacestring("\"", Dynafitpath,"") Dynafitpath = Dynafitpath + "/IGOR_Dynadata" igorscript = replacestring("/", Dynafitpath, ":") igorscript = "Macintosh HD"+ igorscript break case "Windows": Dynafitpath = replacestring("\\", Dynafitpath , "",1,2) Dynafitpath = replacestring("\"", Dynafitpath,"") Dynafitpath = replacestring("\\", Dynafitpath, ":") igorscript = Dynafitpath + "IGOR_Dynadata" igorscript = replacestring (" ", igorscript, "") endswitch getfilefolderinfo/Z igorscript if (v_flag == 0 && v_isfolder) else Print "Create New Directory Dynadata", igorscript newpath/C tmppath, igorscript killpath/Z tmppath endif else Abort " Cannot parse script file to find output directory" endif if(replaceparam(script,"extension","data" , "igxt", force = "True") == 1) Notebook DynaFitScript getData = 1 script = S_value endif else Abort "Only Simulate scripts can be run and analysed! " endif end //-------------------------------------------------------------------------------------------------------------------------------- function/s findparam(script, searchstring, section) string script, searchstring string section string param variable secstartloc, secendloc, secheaderlen , searchstringloc variable paramstartloc, paramendloc, colonloc section = "[" + section + "]" //print section secheaderlen = strlen(section) secstartloc = strsearch(script,section, 0) secendloc = strsearch(script,"[", (secstartloc+secheaderlen)) //print secendloc searchstringloc = strsearch(script, searchstring , secstartloc) //print searchstringloc if (searchstringloc < secendloc) paramstartloc = searchstringloc + strlen(searchstring) paramendloc = strsearch(script, "\r" , paramstartloc) colonloc = strsearch(script, ";", paramstartloc) if (colonloc < paramendloc && colonloc != -1) paramendloc = colonloc endif param = script[paramstartloc, paramendloc-1] printf "Parameter for %s is: %s ", searchstring, param print " " return param else return "" endif end //-------------------------------------------------------------------------------------------------------------------------------- function replaceparam(script, searchstring, section , newparam, [force]) string script, searchstring string section, newparam, force string param string prescript, postscript variable secstartloc, secendloc, secheaderlen , searchstringloc variable paramstartloc, paramendloc, colonloc section = "[" + section + "]" //print section secheaderlen = strlen(section) secstartloc = strsearch(script,section, 0) secendloc = strsearch(script,"[", (secstartloc+secheaderlen)) //print secendloc searchstringloc = strsearch(script, searchstring , secstartloc) //print searchstringloc if (searchstringloc < secendloc && searchstringloc != -1) paramstartloc = searchstringloc + strlen(searchstring) paramendloc = strsearch(script, "\r" , paramstartloc) print paramendloc colonloc = strsearch(script, ";", paramstartloc) print colonloc if (colonloc < paramendloc && colonloc != -1) paramendloc = colonloc endif prescript = script[0 , paramstartloc] postscript = script [paramendloc, strlen(script)] script = prescript + newparam + postscript print "new param:", newparam Notebook DynaFitScript selection={startOfFile, endOfFile} , text = script return 1 elseif (paramisdefault(force) !=1) if (stringmatch(force, "True") == 1) prescript = script [ 0, secstartloc + strlen(section)] postscript = script [ secstartloc + strlen(section) +1 , inf] script = prescript + "\r" + searchstring + " " + newparam + "\r" + postscript Notebook DynaFitScript selection={startOfFile, endOfFile} , text = script return 1 endif else print "Exit replace" return 0 endif end //-------------------------------------------------------------------------------------------------------------------------------- Function writescriptfile() wave/T var = Dynafit_var wave/T val = Dynafit_value string Dynafitpath,cmd, filelist, filename,fileprefix variable fileno, wavepoint, writelen, fstart nvar overwrite = overwrite svar script_fname svar OS =OS Dowindow DynaFitScript if (V_flag == 0) Abort "Unable to Find Dynafit Notebook Window, Please Import script" endif Findvalue /Text = "Dynafit Location" var if (V_value != -1) Dynafitpath = val[V_value] Strswitch(OS) Case "Macintosh": Dynafitpath = replacestring("\\", dynafitpath,"") Dynafitpath = replacestring("\"", dynafitpath,"") Dynafitpath = replacestring("/", dynafitpath,":") Dynafitpath = "Macintosh HD" + Dynafitpath + ":IGOR_Scripts" break case "windows": Dynafitpath = replacestring("\\", dynafitpath,"",1,2) Dynafitpath = replacestring("\"", dynafitpath,"") Dynafitpath = replacestring("\\", dynafitpath,":") Dynafitpath = Dynafitpath + "IGOR_Scripts" endswitch Getfilefolderinfo /Z Dynafitpath if(V_flag == 0 && V_isfolder) newpath scriptpath, Dynafitpath filelist = indexedfile(scriptpath, -1 , ".txt") filelist = listmatch(filelist, "IGOR_Script*",";") filelist = sortfile(filelist) filename = stringfromlist( itemsinlist(filelist)-1 ,filelist) Print "Lastfile:", filename sscanf filename, "IGOR_Script%d.txt", fileno string tmpstr //sscanf filename, "%s%4d%*[.txt]", tmpstr, fileno //print "filePrefix:", tmpstr print "Fileno:", Fileno fileno += 1 sprintf filename, "IGOR_Script%d.txt", fileno else newpath/C scriptpath, Dynafitpath filename = "IGOR_Script1.txt" endif Dowindow DynaFitScript if (V_flag == 0) Abort "Unable to Find Dynafit Notebook Window, Please Import script" endif Notebook DynaFitScript getData = 1 String script = S_value Strswitch(OS) Case "Macintosh": script =replacestring("\r", script, "\n") // Igor inserts Linefeed By \r but Dynafit needs \n break case "Windows": script =replacestring ("\r", script, "\r\n") endswitch if (overwrite == 1) if (strlen(script_fname) != 0) script_fname = replacestring(".txt", script_fname,"") script_fname = script_fname + ".txt" filename = script_fname else script_fname = filename endif else script_fname = filename endif open/P=scriptpath fileno as filename Print "Creating script file:" ,filename writelen = 1000 fstart = 0 do if (writelen < strlen(script)) fprintf fileno, "%s", script[fstart, writelen] fstart = writelen + 1 writelen = writelen + 1000 else fprintf fileno , "%s", script[fstart, strlen(script)] break endif while(1) close fileno killpath scriptpath string tmpfileval Strswitch(OS) Case "Macintosh": tmpfileval = "\\\"IGOR_Scripts/" + filename + "\\\"" break case "Windows": tmpfileval = "\\\"IGOR_Scripts\\" + filename + "\\\"" endswitch Findvalue /Text = "ScriptFile Location" var if (V_value != -1) val[v_value] = tmpfileval else insertpoints numpnts(var), 1 , var,val wavepoint = numpnts(Var)-1 var[wavepoint] = "ScriptFile Location" val[wavepoint] = tmpfileval endif else Abort "Cannot Find dyanfit location, please set Dynafit Location" endif end //-------------------------------------------------------------------------------------------------------------------------------- Function getconstants() string Tmpconstants , readline , param, paramvalue, Paramlist String paramvalues1, paramvalues2 Variable Consloc, endloc, paramloc, EOL ,colonloc, wavepoint //Wave/T Con = Dyna_Con //Wave/T Con_val = DynaCon_Value //if (waveexists(Con) == 0) Make/O/T/N=0 Dyna_Con Make/O/T/N=0 DynaCon_Value Wave/T Con = Dyna_Con Wave/T Con_val = DynaCon_Value //endif Dowindow DynaFitScript if (V_flag == 0) Abort "Unable to Find Dynafit Notebook Window, Please Import script" endif Notebook DynaFitScript getData = 1 String script = S_value Consloc = strsearch( script,"[constants]" , 0, 2) if (consloc != -1 ) consloc = consloc + strlen("[constants]") +1 endloc =strsearch(script, "[",consloc,2) paramlist ="" do EOL = strsearch(script,"\r",consloc ,2) //extract line If (EOL < endloc && EOL != -1) readline = script[Consloc, EOL] colonloc = strsearch (readline, ";",0,2) paramloc = strsearch (readline,"=", 0, 2) param = stringfromlist(0 , readline ,"=") splitstring /E = "^\s*([^\s;]*)" param, param paramvalue = stringfromlist(1,readline, "=") splitstring /E = "^\s*([^;]*)" paramvalue, paramvalue printf "%s value is %s \r" param, paramvalue if (strlen(param) > 0 && strlen(paramvalue) > 0) Findvalue /Text = param Con if (V_value == -1) insertpoints numpnts(Con), 1 , Con,Con_val wavepoint = numpnts(Con)-1 Con[wavepoint] = param Con_val[wavepoint] = paramvalue paramlist += param +"="+paramvalue +";" else wavepoint = V_value Con_val[wavepoint] = paramvalue endif endif consloc = EOL +1 else break endif while(1) else return -1 endif Dowindow Dynafit_Constants if (V_flag == 0) Edit/N =Dynafit_Constants Con, Con_val as "DynaConstants" endif print "Paramlist:", paramlist end //-------------------------------------------------------------------------------------------------------------------------------- Function updateconstants() //String ctrlname Variable noconst, i , secloc,secendloc String consectext,tmpstring,param, paramvalue Wave/T Con = Dyna_Con Wave/T Con_val = DynaCon_Value consectext = "" if (waveexists(Con) == 0) Print "No Constants wave found, Hence no constants to update! " return 0 endif noconst = numpnts(Con) for (i = 0 ; i< noconst ; i +=1) param = Con[i] paramvalue = Con_Val[i] tmpstring = param + " = " + paramvalue +"\r" consectext += tmpstring endfor Dowindow DynaFitScript if (V_flag == 0) Abort "Unable to Find Dynafit Notebook Window, Please Import script" endif Notebook DynaFitScript getData = 1 String script = S_value secloc = strsearch(script, "[constants]", 0,2) secendloc = strsearch (script, "[", (secloc + 1) , 2) script = script[ 0 , secloc + strlen("[constants]")] + consectext + script [secendloc, inf] Notebook DynaFitScript selection={startOfFile, endOfFile} , text = script end //-------------------------------------------------------------------------------------------------------------------------------- Function getdatafile() Variable datasecloc, datasecendloc, fileloc1, fileloc2, EOL string readline, filename, param, paramconc Make/O/T/N=0 Datafile Make/O/T/N=0 Fileparam Make/O/T/N=0 Conc_Data Wave/T file = Datafile Wave/T wparam = Fileparam Wave/T wparamConc = Conc_Data Dowindow DynaFitScript if (V_flag == 0) Abort "Unable to Find Dynafit Notebook Window, Please Import script" endif Notebook DynaFitScript getData = 1 String script = S_value datasecloc = strsearch(script, "[data]", 0 , 2) if (datasecloc != -1) datasecendloc = strsearch (script, "[",datasecloc +1, 2) if (datasecendloc == -1) datasecendloc = strlen(script) endif do fileloc1 = strsearch (script, "file", datasecloc, 2) fileloc2 = strsearch(script, "concentration", fileloc1 +1 , 2) // makes sure concentration is after file! if (fileloc1 != -1 && fileloc1 < datasecendloc) EOL = strsearch( script, "\r" , fileloc1, 2) readline = script [ fileloc1, EOL] print readline splitstring /E = "file\s+([^;\r]*)" readline, filename insertpoints numpnts(file), 1 , file, wparam,wparamConc file[numpnts(file)-1] = filename EOL = strsearch(script, "\r", fileloc2, 2) readline = script [ fileloc2, EOL] splitstring /E = "concentration\s+(.*)\s+=\s+([^;]*)" readline, param, paramconc print param, paramconc wparam[numpnts(file)-1] = param wparamconc[numpnts(file)-1] = paramconc datasecloc = EOL + 1 // to make sure dont read \r again and again else break endif while(1) endif end //-------------------------------------------------------------------------------------------------------------------------------- Function Dynafit_load() String pathName // Name of symbolic path or "" to get dialog String fileName, Graphname, Fnameonly String tmpstr wave Xwvname wave tempw Variable index=0 Wave/T var = Dynafit_var Wave/T val = Dynafit_value Wave/T fname = Datafile if (waveexists(var) == 0) Abort "Cannot find dynafit var waves" endif findvalue /Text = "Simout Location" var if (V_value !=-1) string outputdir = val[V_value] print outputdir newpath pathName , outputdir svar basename = basename nvar counter = counter nvar plotswitch =plotswitch graphname = basename + "_Graph" string temp = graphname+"%d" graphname = uniquename(graphname, 6, counter) sscanf graphname, temp, counter Display /N = $graphname/W=(600,100, 1100, 500) print graphname Variable result do // Loop through each file in folder fileName = IndexedFile(pathName, index, ".igxt") if (strlen(fileName) == 0) // No more files? break // Break out of loop endif fnameonly = stringfromlist(0,filename,".igxt") Findvalue /text = fnameonly/TXOP = 4 fname if( v_value != -1) if (waveexists(Xwvname) == 0) // To prevent creation of mutiple X wave, LoadWave/Q/A=Conc/J/D/L={0,0,0,0,1}/P=pathName fileName wave Xwvname = $(stringfromlist (0,S_WaveNames)) endif LoadWave/Q/A=$filename/J/D/L={0,0,0,1,1}/P=pathName fileName wave tempw = $(stringfromlist (0,S_WaveNames)) Appendtograph tempw vs Xwvname ; Delayupdate else Print "Disgreaded File:", filename endif index += 1 while (1) Doupdate else Abort "Cannot find output directory" endif killpath pathname nvar fittype = fittype if (fittype == 1) dynaFitall(graphname) elseif (fittype == 2) FitallDlbexp(graphname) elseif (fittype == 3) fitallline(graphname) endif return 0 // Signifies success. End //-------------------------------------------------------------------------------------------------------------------------------- Function Dynafitall(graphname) string graphname String tracelist = removefit(tracenamelist(graphname,";",1)) variable OWflag = 0, index = 0, tblcreate = 0 variable wvlen String legwave, ratewv, errwv,conc svar basename = basename nvar counter = counter String wavpre = basename legwave = wavpre +"_Legend" + num2str(counter) Print "Legend wavename:", legwave ratewv = wavpre +"_Rate"+ num2str(counter) errwv = wavpre +"_Err"+ num2str(counter) conc = wavpre +"_Conc"+ num2str(counter) do string tmp = stringfromlist(index, tracelist) if (strlen(tmp) == 0) break endif string wvname, prefix, suffix prefix = tmp wave w1 = tracenametowaveref(graphname,tmp) wvname = nameofwave(w1) wave w2 = Xwavereffromtrace(graphname,tmp) if (waveexists($legwave)==0) Make/T/N=0 $legwave Make/D/O/N=0 $ratewv Make/D/O/N=0 $errwv tblcreate = 1 endif wvlen = numpnts(w2) Make/O/D/N=(wvlen) tmp1 Variable xtagpoint = 3*(numpnts(w2))/4 print wvname //_____________________________ if (waveexists(w1)) Curvefit/M=1/w= 2 exp, w1 /X=w2/D=tmp1 String Coeffwave = wvname + "_Coeff" String Sigmawave = wvname + "_Sigma" wvname="fit_"+wvname if (waveexists($wvname)==1) print "Exists? : " , wvname removefromgraph/Z/w=$graphname $wvname killwaves $wvname endif Duplicate/O tmp1 $wvname Appendtograph/W=$graphname $wvname vs w2 Modifygraph/W=$graphname rgb($wvname) = (0,0,0) wave w1 = W_Coef wave w2 = W_Sigma Variable tau = w1(2) Variable Sigma = w2(2) wave/T wt = $legwave //wt because w1 is used as number wave already wave w2 = $Ratewv wave w3 = $Errwv string uid = prefix wvlen = numpnts(wt) Print "FInding Text: ", uid Findvalue/Text = uid/TXOP=4 wt Variable dimno = V_value print "Found text at:", dimno if(dimno== -1) wvlen = numpnts(wt) Print " Writing at: ", wvlen insertpoints wvlen,1,wt insertpoints wvlen,1,w2 insertpoints wvlen,1,w3 wt[wvlen] = uid w2[wvlen] = tau w3[wvlen] = Sigma else if(OWflag == 0) String prmstring = "OverWrite Previous fit values?:" + uid Doalert /T = "Duplicate/Overwrite" 1, prmstring endif if( V_Flag ==2 && OWflag ==0 ) wvlen = numpnts(wt) insertpoints wvlen,1,wt insertpoints wvlen,1,w2 insertpoints wvlen,1,w3 wt[wvlen] = uid w2[wvlen] = tau w3[wvlen] = Sigma else OWflag = 1 w2[dimno] = tau w3[dimno] = Sigma endif endif endif index +=1 while(1) killwaves tmp1 String Tablenm if (waveexists($Conc) == 0) make/O/N=(index) $Conc print"Making Conc wave:", Conc wave Wc = $conc endif svar basename = basename nvar counter = counter tablenm = basename +"_Table" string temp = tablenm +"%d" tablenm = uniquename(tablenm, 7, counter) sscanf tablenm, temp, counter Dowindow $tablenm if(V_flag==0) Wave/T con = Dyna_Con Wave/T Val = DynaCon_Value String tmpw1 = uniqueName("Dyna_Con",1, 0) Duplicate Con $tmpw1 String tmpw2 = uniqueName("DynaCon_Value",1, 0) Duplicate val $tmpw2 if (waveexists(con) == 0) edit/N=$tablenm wt,w2,w3,wc DoAlert/T= "Constant wave Missing" 0, "Warning: Cannot access DynaFit Constants Wave, use Update param!!" else print wt,w2,w3,wc,tmpw1,tmpw2 edit/N=$tablenm wt,w2,w3,wc, $tmpw1, $tmpw2 endif endif plotrate(wt,w2,w3,wc) end //-------------------------------------------------------------------------------------------------------------------------------- Function plotrate(wt,w2,w3,wc) wave/T wt wave w2, w3, wc wave/T file = Datafile wave/T Conc = Conc_data variable i if (waveexists(conc) == 0 || waveexists(file) == 0) Print "Unable to find File info wave" else for ( i = 0 ; i < numpnts(file); i+=1) String filename = file[i] Findvalue/text = filename wt if (V_Value !=-1) if( numtype(str2num(Conc[i])) !=2) wc[V_value] = str2num(Conc[i]) else wc[V_value] = i endif else print "Unable to find file:" ,filename endif endfor endif sort wc,wt,w2,w3,wc svar plotgraph Dowindow/f $plotgraph if (V_flag == 0) Display/n = $plotgraph endif Appendtograph/W = $plotgraph w2 vs wc end //-------------------------------------------------------------------------------------------------------------------------------- function /S removefit(wvlist) string wvlist variable index = 0 variable listlen = itemsinlist(wvlist) if (listlen == 0) return "NULL" endif do string tempitem = stringfromlist(index, wvlist) if (strlen(tempitem) == 0) break endif if (stringmatch(tempitem, "*fit_*") ==1) wvlist = removefromlist (tempitem, wvlist) else index +=1 endif while (1) return wvlist end //-------------------------------------------------------------------------------------------------------------------------------- Function Updateparam(ctrlname) string ctrlname getdatafile() getconstants() bring2front("Dynafit_Constants") bring2front("DynafitScript") end Function /S sortfile(filename) string filename Make/D/O/N=0 Fileno Make/T/O/N=0 Fname Wave/T name = Fname Wave no = fileno variable i , j for (i = 0; i