#pragma TextEncoding = "UTF-8" #pragma rtGlobals=3 #pragma version=1.06 #pragma igorVersion=7 #pragma IndependentModule=UserProcLoader // https://www.wavemetrics.com/user/tony // provides an easy way to load and unload procedure files from the User // Procedures or Wavemetrics Procedures folders. See also Thomas Braun's // code to do the same thing at https://www.wavemetrics.com/node/8189 // requires Igor Pro 8 for full functionality // in Igor 7 it's possible to select procedures that cannot be unloaded // trying to load a procedure that won't compile could lead to confusion. // UserProcLoader won't be able to unload the file until compilation is completed. menu "Macros" "Load or Unload...",/Q, makeProcLoaderPanel() end function makeProcLoaderPanel() dowindow /k LoaderPanel NewDataFolder /O root:Packages NewDataFolder /O root:Packages:procLoader DFREF dfr=root:Packages:procLoader // prepare waves for two listboxes make /o /n=0 dfr:w_loadedSelection /WAVE=w_loadedSelection, dfr:w_unloadedSelection /WAVE=w_unloadedSelection make /o /n=0/T dfr:w_loadedProcs, dfr:w_unloadedProcs, dfr:w_loadedTitle, dfr:w_unloadedTitle wave /SDFR=dfr/T w_loadedProcs, w_unloadedProcs, w_loadedTitle, w_unloadedTitle w_loadedTitle={"loaded"}; w_unloadedTitle={"unloaded"} // create panel NewPanel /K=1/N=LoaderPanel/W=(20,20,520,380) as "Load or Unload Procedures" ModifyPanel /W=LoaderPanel fixedSize=1, noedit=1 // popup to select procedures folder on disk popupMenu popupFolder, win=LoaderPanel, pos={20, 10}, value="User Procedures;Wavemetrics Procedures", proc=loaderPopMenuProc // button to open Procedure Browser window (useful if you want to open procedure after loading) button buttonBrowser, win=LoaderPanel, pos={460, 15}, size={15,14}, picture=thumb, labelBack=0, title="", proc=loaderButtonProc, help={"Open Procedure Browser"} // listbox for procedure files in folder that are not currently loaded ListBox listboxUnloaded,win=LoaderPanel, pos={20, 40},size={200, 300}, listwave=w_unloadedProcs, selwave=w_unloadedSelection, mode=9 ListBox listboxUnloaded,win=LoaderPanel, fsize=12, proc=loaderListBoxProc, titleWave=w_unloadedTitle // buttons to be enabled when a valid selection is made from a listbox button buttonLoad win=LoaderPanel, pos={230,120},size={40,40},title=">", proc=loaderButtonProc, disable=2 button buttonUnload win=LoaderPanel, pos={230,170},size={40,40},title="<", proc=loaderButtonProc, disable=2 // listbox for procedure files in folder that ARE currently loaded ListBox listboxLoaded,win=LoaderPanel, mode=9, selwave=w_loadedSelection, pos={280, 40},size={200, 300}, editstyle=1 ListBox listboxLoaded,win=LoaderPanel, listwave=w_loadedProcs,fsize=12, proc=loaderListBoxProc, titleWave=w_loadedTitle // populate listbox waves updateListboxWaves() return 1 end function loaderButtonProc(ba) STRUCT WMButtonAction &ba if(ba.eventCode!=2) return 0 endif if(stringmatch(ba.ctrlName, "buttonBrowser")) doigorMenu "Windows", "Procedure Browser" return 0 endif DFREF dfr=root:Packages:procLoader wave /SDFR=dfr w_loadedProcs, w_loadedSelection, w_unloadedProcs, w_unloadedSelection variable i string cmd if(stringmatch(ba.ctrlName, "buttonLoad")) wave w_sel=dfr:w_unloadedSelection wave /T w_list=dfr:w_unloadedProcs cmd="INSERTINCLUDE" else wave w_sel=dfr:w_loadedSelection wave /T w_list=dfr:w_loadedProcs cmd="DELETEINCLUDE" endif string startquote=selectString(SelectedFolder()-1, "\"", "<") string endquote=selectString(SelectedFolder()-1, "\"", ">") string strExct for(i=0;imaxLevels) || (folderLimit && (folderCount-folderIndex)>folderLimit)) break endif while(1) killpath /Z tempPathFF return fileList end // returns item selected in popup // 1: User Procedures 2: Wavemetrics Procedures function SelectedFolder() controlinfo /W=LoaderPanel popupFolder if (V_flag<1) return 0 endif return V_Value end // strip trailing stuff in the output from winlist function /S filenameFromString(s) string s SplitString/E=".*\.ipf" s // remove module names return removeending(s_value, ".ipf") end // extract quoted filename from include statement function /S filenameFromIncludeStatement(s) string s if (numtype(strlen(s))==2) return "" endif string startquote=selectString(SelectedFolder()-1, "\"", "<") string endquote=selectString(SelectedFolder()-1, "\"", ">") variable start, stop start=strsearch(s, startquote, 0) stop=strsearch(s, endquote, start+1) if (start==-1 || stop==-1) return "" endif return s[start+1,stop-1] end // truth that string s is a member of textwave w function isInTextWave(s, w) string s wave /T w if(numtype(strlen(s))==2) return 0 endif FindValue /TEXT=s/TXOP=4 /Z w return (V_Value>-1) end // remove empty points from textwave w function zapBlanks(w) wave /T w if(numpnts(w)==0) return 0 endif variable i=0 do if(stringmatch(w[i],"")) deletepoints i,1,w else i+=1 endif while(iHX.,7PocZV:W6E^l,aImEkaM]:*'m bL`L6pfSJJc63O+3ANeuTl'kA,hOWe93S-G[q*-P6FrcH'TnrT4.>cLlR_KAXsdKjN",$]&0nO+B&R ">RL]CN;`9._&d][6h'7(^>`1g1:YEMd]WVWriKZkEi[R2%1^O9gfP#?=&qC%a9eZ(_EhMq:"*r[P( KYl.*a,BQsH@RWK&3?uap)g+'eI@0A8Pps!/h+sK/DUP6@0D;B_m,>;ai(")=K[B&aRSE%6V,0L-n&spJ1TU05@M f319f>^S[jh"m35c&+[WA_9$^@M3L;Cr>M0ud?+mCG\D)[i!6,-,m$C_6lSZh0D=ZLU`^-jE(L_/a+ @f3_e&j>Z+=DRP`\rK#QD&4D5Whg)JX6sW6K#Te`(hHA'h=\a7nTbMA)&$++2'5n%3),AA>ckQTTDn [.T'-Fq5Ptp$CkW#c*j.arR/OEDrcr-lYIG0j,k7=iA&VI'^(DJ2.>=jc*pe%TXfX21WitUGK?%te4 %&aEV)R%LR&uYtK$hc9'lJ(K_DRcVlV"d84.NhbMo_HN78f(sE/-nMMo!p_PPO:X(_.>Mk+uG"-8.R WPVW-g@/EC]CSaC>1;k6[M;iS52`f"sQc\`]A>7m@%\'1=+PaWqkMMU>3+#\%bW-',UhH[38oH,Q=" _UMT\pp3]\I#$;cf3KSY5,^QcpuT(,I#S_&),;?$A@f7XJEo4d:R20_fV17S)m1(cR/r&,M(gf0e.1\fs>\Nr;6cL'X^#Nq23XINefNoU6ZRT;&.r>INp.<*Bdb3LR g=leH?k^JTssf?)=[jEsr;H]%PBL@fE8TbM)"'uYHIpj>ZC*B%+!p\T"nD"rBLe6_`D=nNZ3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