#pragma TextEncoding = "UTF-8" #pragma rtGlobals=3 // Use modern global access method and strict wave access #pragma DefaultTab={3,20,4} // Set default tab width in Igor Pro 9 and later Function Filter_by_wave() //You have a bunch of waves and want to filter on one value. //Have your waves in one table //This only works if all the waves in a table exist in the same folder //You also need to be in the correct data folder--the same as the waves shown in the table--or it'll show no waves String startingDataFolder startingDataFolder = getDataFolder(1) PRINT "You are starting in this data folder:", startingDataFolder PRINT "" string ListStr listStr = Wavelist("*",";","WIN:") IF(Strlen(listStr)==0) Print "-You have no selectable waves to operate on \r check whether you're in the correct data folder \r and that it matches the table you've selected" Return -1 Endif PRINT "THis function helps you manipulate the waves in the table like a dataframe" PRINT "" Variable comparitor, what_operation String whatWave, newName, stringComparitor Prompt whatWave, "Based on wich wave do you want filter the data?", popup, listStr Prompt newName, "Please give a (well-formed) name for the destination folder. It will be placed in the current folder" Prompt comparitor, "If you're comparing numbers, please enter it here" Prompt stringComparitor, "If you're trying to match or exclude by text, please enter it here" Prompt what_operation, "For numbers: 0 to exclude everything else, 1 to exclude this, 2 to select everything greater than or equal to, 3 to select everything less than or equal to. TEXT: 4 to match exactly, 5 to include text (* as wild card allowed), 6 to include text (* as wild card allowed), 7 to exclude exactly" DoPrompt "Chose wisely", whatWave, comparitor, stringComparitor, newName, what_operation String dataFolderNamingString = whatWave+"_"+newName NewDataFolder/O $dataFolderNamingString // Print dataFolderNamingString Variable lengthofWave lengthofWave = NumPnts($whatWave) Duplicate/O/Free $whatWave tempWave Switch(what_operation) Case 0: EXTRACT/INDX tempWave, indexWave, tempWave != comparitor break Case 1: EXTRACT/INDX tempWave, indexWave, tempWave == comparitor break Case 2: EXTRACT/INDX tempWave, indexWave, tempWave < comparitor break Case 3: EXTRACT/INDX tempWave, indexWave, tempWave > comparitor break Case 4: wave/T textTempwave = $whatWave Duplicate/O/Free $whatWave tempWave Extract/INDX textTempwave, indexWave, ( CmpStr(textTempwave, stringComparitor, 0) != 0) break Case 5: wave/T textTempwave = $whatWave Duplicate/O/Free $whatWave tempWave Extract/INDX textTempwave, indexWave, ( stringmatch(textTempwave, stringComparitor) == 0) break Case 6: wave/T textTempwave = $whatWave Duplicate/O/Free $whatWave tempWave Extract/INDX textTempwave, indexWave, ( stringmatch(textTempwave, stringComparitor) != 0) break Case 7: wave/T textTempwave = $whatWave Duplicate/O/Free $whatWave tempWave Extract/INDX textTempwave, indexWave, ( CmpStr(textTempwave, stringComparitor, 0) == 0) break EndSwitch Variable ii, jj String waveNameInLoop FOR(ii=0;ii-1;jj-=1) // This for loop iterates accross all relevant waves waveNameInLoop=StringFromList(ii,listStr) // PRINT "waveNameInLoop", waveNameInLoop pathString = GetDataFolder(1) pathString += dataFolderNamingString+":"+waveNameInLoop DeletePoints indexWave[jj],1, $pathString // PRINT "JJ is",jj ENDFOR ENDFOR KillWaves indexWave SetDataFolder $dataFolderNamingString // PRINT "dataFolderNamingString",dataFolderNamingString PRINT "The table that pops up is showing the waves placed in:", GetDataFolder(1) PRINT "" listStr = Wavelist("*",";","") // PRINT listStr Variable kk FOR(kk=0;kk0) Duplicate/O tempWave_out $NewWaveNamingString AppendtoTable $NewWaveNamingString Return 1 Endif PRINT "You didn't supply a name for the outwave--look for tempWave_out" Return 1 Endif Duplicate/T/O/Free $whatWave tempWave Extract/INDX tempWave, indexWave, ( stringmatch(tempWave, stringComparitor) == 1 || stringmatch(tempWave, stringComparitor2) == 1 || stringmatch(tempWave, stringComparitor3) == 1) indexWave_length = Numpnts(indexWave) String newEntryCheck newEntryCheck = "*"+newEntry+"*" // PRINT newEntryCheck For(ii=0; ii