Skip to content

Commit cfc5401

Browse files
authoredDec 19, 2024
Merge pull request #2315 from AllenInstitute/feature/2315-enhance-get-row-index
GetRowIndex: Add textOp optional parameter
2 parents 8c0b7b9 + 6cc5fd2 commit cfc5401

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed
 

‎Packages/MIES/MIES_Utilities_Algorithm.ipf

+7-3
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ End
259259
/// @brief Return the row index of the given value, string converted to a variable, or wv
260260
///
261261
/// Assumes wv being one dimensional and does not use any tolerance for numerical values.
262-
threadsafe Function GetRowIndex(WAVE wv, [variable val, string str, WAVE/Z refWave, variable reverseSearch])
262+
threadsafe Function GetRowIndex(WAVE wv, [variable val, string str, WAVE/Z refWave, variable reverseSearch, variable textOp])
263263

264264
variable numEntries, i
265265

@@ -271,6 +271,10 @@ threadsafe Function GetRowIndex(WAVE wv, [variable val, string str, WAVE/Z refWa
271271
reverseSearch = !!reverseSearch
272272
endif
273273

274+
if(ParamIsDefault(textOp))
275+
textOp = 4
276+
endif
277+
274278
if(!ParamIsDefault(refWave))
275279
ASSERT_TS(IsWaveRefWave(wv), "wv must be a wave holding wave references")
276280
numEntries = DimSize(wv, ROWS)
@@ -336,9 +340,9 @@ threadsafe Function GetRowIndex(WAVE wv, [variable val, string str, WAVE/Z refWa
336340
endif
337341

338342
if(!reverseSearch)
339-
FindValue/TEXT=(str)/TXOP=4 wv
343+
FindValue/TEXT=(str)/TXOP=(textOp) wv
340344
else
341-
FindValue/TEXT=(str)/TXOP=4/R wv
345+
FindValue/TEXT=(str)/TXOP=(textOp)/R wv
342346
endif
343347

344348
if(V_Value >= 0)

‎Packages/tests/Basic/UTF_Utils_Algorithm.ipf

+9
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,15 @@ static Function TestGetRowIndex()
205205
CHECK_EQUAL_VAR(GetRowIndex(textWave, str = "b"), 1)
206206
CHECK_EQUAL_VAR(GetRowIndex(textWave, val = 123), NaN)
207207

208+
// text waves with textOp
209+
Make/FREE/T textWave = {"a1", "b2", "c", "d", "1", "2"}
210+
CHECK_EQUAL_VAR(GetRowIndex(textWave, val = 1), 4)
211+
CHECK_EQUAL_VAR(GetRowIndex(textWave, val = 1, textOp = 4), 4)
212+
CHECK_EQUAL_VAR(GetRowIndex(textWave, val = 1, textOp = 0), 0)
213+
CHECK_EQUAL_VAR(GetRowIndex(textWave, str = "2"), 5)
214+
CHECK_EQUAL_VAR(GetRowIndex(textWave, str = "2", textOp = 4), 5)
215+
CHECK_EQUAL_VAR(GetRowIndex(textWave, str = "2", textOp = 0), 1)
216+
208217
// wave ref waves
209218
Make/FREE/WAVE/N=2 waveRefWave
210219
Make/FREE content

0 commit comments

Comments
 (0)