#pragma TextEncoding = "UTF-8" #pragma rtGlobals=3 // Use modern global access method and strict wave access. // generic text file (GTF) loader // by tony.withers@uwo.ca // GUI for choosing files to load and editing the names of waves to be created. // this version assumes one wave per file. // 21 Nov 2017 adapted for itx files. not tested. menu "Macros" // a better place to put this would be in the Load Waves menu. "Load lots of itx files...", /Q, MakeGTFLoaderPanel() end function MakeGTFLoaderPanel() dowindow /k GTFLoaderPanel NewDataFolder /O root:Packages NewDataFolder /O root:Packages:GTF DFREF dfr=root:Packages:GTF make /o /n=(0,2)/T dfr:w_newList /WAVE=w_newList make /o/W/U /n=(3,5) dfr:w_color/WAVE=w_color w_color={{0,0,0},{65535,0,0},{0,65535,0},{0,0,65535},{0,65535,65535}} MatrixTranspose w_color // easier to enter as 3 rows, 5 cols make /o /n=(0,2,3) dfr:w_selection /WAVE=w_selection SetDimLabel 2,1,backColors,w_selection // define plane 1 as background colors SetDimLabel 2,2,foreColors,w_selection make /o /n=2 /T dfr:w_titles /wave=w_titles w_titles={"file","output"} string /G dfr:s_edit="" NewPanel /K=1/N=GTFLoaderPanel/W=(20,20,710,380) as "GTF Loader" ModifyPanel /W=GTFLoaderPanel fixedSize=1, noedit=1 button buttonSelectFiles win=GTFLoaderPanel, pos={10,10},size={80,20},title="select files", proc=GTFButtons setvariable setvarLen win=GTFLoaderPanel, fsize=12, pos={450,10},size={230,20},title="character limit for wave names:",value=_NUM:29, limits={10,29,1}, proc=GTFSetvar ListBox listboxOut,win=GTFLoaderPanel, mode=9, selwave=w_selection, titlewave=w_titles, pos={10, 40},size={670, 280}, editstyle=1 ListBox listboxOut,win=GTFLoaderPanel, colorwave=w_color, listwave=w_newList,widths={50,50}, fsize=12, proc=GTFListBox, userColumnResize=1 Button buttonDoIt win=GTFLoaderPanel,pos={630,330},size={50,20},title="Do It", proc=GTFButtons Button buttonCancel win=GTFLoaderPanel,pos={560,330},size={60,20},title="Cancel", proc=GTFButtons end function GTFSetVar(s) : SetVariableControl STRUCT WMSetVariableAction &s if(s.eventCode==-1) return 0 endif if(stringmatch(s.ctrlName, "setvarLen")) GTFSanityCheck() endif end function GTFButtons(ba) STRUCT WMButtonAction &ba DFREF dfr=root:Packages:GTF wave /T w_newList=dfr:w_newList wave w_selection=dfr:w_selection wave w_color=dfr:w_color variable i switch( ba.eventCode ) case 2: // mouse up if(stringmatch(ba.ctrlName, "buttonSelectFiles")) // ***** edited to select itx files: ****** String fileFilters = "Data Files (*.itx):.itx;" open /D/R/F=fileFilters/MULT=1 refnum if(strlen(S_fileName)==0) return 0 endif redimension /N=(itemsinlist(S_fileName,"\r"), 2) w_newList w_newList[][0]=stringfromlist(p,S_fileName,"\r") w_newList[][1]=parsefilepath(3, stringfromlist(p,S_fileName,"\r"), ":", 0,0) w_newList[][1]=selectstring (strlen(w_newList[p][1])>28, w_newList[p][1], (w_newList[p][1])[0,27]) w_newList[][1]=cleanupname(w_newList[p][1],0) redimension /n=(itemsinlist(S_fileName,"\r"),3,3) w_selection w_selection[][1][0]=2 GTFSanityCheck() elseif(stringmatch(ba.ctrlName, "buttonDoIt")) for(i=0;iv_value, listWave[p][1], (listWave[p][1])[0,v_value-1]) for (i=0; i