#pragma rtGlobals=1 // Use modern global access method. #pragma version=5.0 #pragma IgorVersion=6.1 // contains general utility procedures for: // file open dialogs // paths // lists to waves (and the reverse) // // and BETA procedures for: // generating MRED lists // guessing of transmission file assignments // // - these files may or may not be NCNR-specific. They may eventually // need to be moved into NCNR_Utils, or to more appropriate locations // // // 29MAR07 SRK // ////////////////////// // "intelligent" differentiation of the data files based on information gathered while // getting the FIle Catalog. Uses some waves that are generated there, but not displayed in the table // // See CatVSTable.ipf for where these files are created (and sorted to keep them together) //////////// //testing - unused // Function/S TextWave2SemiList(textW) Wave/T textW String list="" Variable num=numpnts(textW),ii=0 do list += textw[ii] + ";" ii+=1 while(ii=0 if found // Function FindStringInLabel(num,findThisStr) Variable num String findThisStr Wave/T w = $"root:myGlobals:CatVSHeaderInfo:Labels" Wave RunNumber = $"root:myGlobals:CatVSHeaderInfo:RunNumber" if( (WaveExists(w) == 0 ) || (WaveExists(RunNumber) == 0 ) ) return(0) endif Variable pts=numpnts(RunNumber),ii,loc for(ii=0;ii=0 if found end //rStr is the global string, already atSDD (so there should be only one instance of // empty and one instance of blocked // //scan through the list, and remove those that are have "empty" or "blocked" in the label // or anything that is listed in StrToFind // Function/S RemoveEmptyBlocked(list,StrToFind) String list,StrToFind Variable ii,num,temp num=ItemsInList(list ,",") for(ii=0;ii // MatchList(matchStr,list,sep) // Returns the items of the list whose items match matchStr // The lists are separated by the sep character, usually ";" // // matchStr may be something like "abc", in which case it is identical to CmpStr // matchStr may also be "*" to match anything, "abc*" to match anything starting with "abc", // "*abc" to match anything ending with "abc". // matchStr may also begin with "!" to indicate a match to anything not matching the rest of // the pattern. // At most one "*" and one "!" are allowed in matchStr, otherwise the results are not guaranteed. // Function/S MyMatchList(matchStr,list,sep) String matchStr,list,sep String item,outList="" Variable n=strlen(list) Variable en,st=0 do en= strsearch(list,sep,st) if( en < 0 ) if( st < n-1 ) en= n // no trailing separator sep="" // don't put sep in output, either else break // no more items in list endif endif item=list[st,en-1] if( MyStrMatch(matchStr,item) == 0 ) outlist += item+sep Endif st=en+1 while (st < n ) // exit is by break, above return outlist End //the following is a WaveMetrics procedure from // StrMatch(matchStr,str) // Returns 0 if the pattern in matchStr matches str, else it returns 1 // // matchStr may be something like "abc", in which case it is identical to CmpStr // matchStr may also be "*" to match anything, "abc*" to match anything starting with "abc", // "*abc" to match anything ending with "abc". // matchStr may also begin with "!" to indicate a match to anything not matching the rest of // the pattern. // At most one "*" and one "!" are allowed in matchStr, otherwise the results are not guaranteed. // Function MyStrMatch(matchStr,str) String matchStr,str Variable match = 1 // 0 means match Variable invert= strsearch(matchStr,"!",0) == 0 if( invert ) matchStr[0,0]="" // remove the "!" endif Variable st=0,en=strlen(str)-1 Variable starPos= strsearch(matchStr,"*",0) if( starPos >= 0 ) // have a star if( starPos == 0 ) // at start matchStr[0,0]="" // remove star at start else // at end matchStr[starPos,999999]="" // remove star and rest of (ignored, illegal) pattern endif Variable len=strlen(matchStr) if( len > 0 ) if(starPos == 0) // star at start, match must be at end st=en-len+1 else en=len-1 // star at end, match at start endif else str="" // so that "*" matches anything endif endif match= !CmpStr(matchStr,str[st,en])==0 // 1 or 0 if( invert ) match= 1-match endif return match End