diff --git a/Packages/MIES/MIES_Utilities_Algorithm.ipf b/Packages/MIES/MIES_Utilities_Algorithm.ipf index c6c72fd28d..59115c7453 100644 --- a/Packages/MIES/MIES_Utilities_Algorithm.ipf +++ b/Packages/MIES/MIES_Utilities_Algorithm.ipf @@ -259,7 +259,7 @@ End /// @brief Return the row index of the given value, string converted to a variable, or wv /// /// Assumes wv being one dimensional and does not use any tolerance for numerical values. -threadsafe Function GetRowIndex(WAVE wv, [variable val, string str, WAVE/Z refWave, variable reverseSearch]) +threadsafe Function GetRowIndex(WAVE wv, [variable val, string str, WAVE/Z refWave, variable reverseSearch, variable textOp]) variable numEntries, i @@ -271,6 +271,10 @@ threadsafe Function GetRowIndex(WAVE wv, [variable val, string str, WAVE/Z refWa reverseSearch = !!reverseSearch endif + if(ParamIsDefault(textOp)) + textOp = 4 + endif + if(!ParamIsDefault(refWave)) ASSERT_TS(IsWaveRefWave(wv), "wv must be a wave holding wave references") numEntries = DimSize(wv, ROWS) @@ -336,9 +340,9 @@ threadsafe Function GetRowIndex(WAVE wv, [variable val, string str, WAVE/Z refWa endif if(!reverseSearch) - FindValue/TEXT=(str)/TXOP=4 wv + FindValue/TEXT=(str)/TXOP=(textOp) wv else - FindValue/TEXT=(str)/TXOP=4/R wv + FindValue/TEXT=(str)/TXOP=(textOp)/R wv endif if(V_Value >= 0) diff --git a/Packages/tests/Basic/UTF_Utils_Algorithm.ipf b/Packages/tests/Basic/UTF_Utils_Algorithm.ipf index 95381a902b..8dc07231fe 100644 --- a/Packages/tests/Basic/UTF_Utils_Algorithm.ipf +++ b/Packages/tests/Basic/UTF_Utils_Algorithm.ipf @@ -205,6 +205,15 @@ static Function TestGetRowIndex() CHECK_EQUAL_VAR(GetRowIndex(textWave, str = "b"), 1) CHECK_EQUAL_VAR(GetRowIndex(textWave, val = 123), NaN) + // text waves with textOp + Make/FREE/T textWave = {"a1", "b2", "c", "d", "1", "2"} + CHECK_EQUAL_VAR(GetRowIndex(textWave, val = 1), 4) + CHECK_EQUAL_VAR(GetRowIndex(textWave, val = 1, textOp = 4), 4) + CHECK_EQUAL_VAR(GetRowIndex(textWave, val = 1, textOp = 0), 0) + CHECK_EQUAL_VAR(GetRowIndex(textWave, str = "2"), 5) + CHECK_EQUAL_VAR(GetRowIndex(textWave, str = "2", textOp = 4), 5) + CHECK_EQUAL_VAR(GetRowIndex(textWave, str = "2", textOp = 0), 1) + // wave ref waves Make/FREE/WAVE/N=2 waveRefWave Make/FREE content