AW: Searches of a list

Rudolf Bargholz rudolf at bargholz.ch
Sun Jan 1 08:10:22 UTC 2023


Hi Das,

A $search loops through the list lines, and normally you want to test each line for a pattern in one of the columns in that list line. For this I tend to use "$ref." in my search structure.

pos('b',low(ilMasterList.CB_SPEC))>0|pos('b',low(ilMasterList.CB_COMM)
> )>0|pos('b',low(ilMasterList.CB_NAME))>0|pos('b',low(ilMasterList.CB2_
> CER))>0|pos('b',low(ilMasterList.CB_MAST))>0

becomes

pos('b',low($ref.CB_SPEC))>0|pos('b',low(($ref.CB_COMM))>0|pos('b',low(($ref.CB_NAME))>0|pos('b',low(($ref.CB2_
> CER))>0|pos('b',low(($ref.CB_MAST))>0

So your search would be 

Do ilMasterList.$search([icSearchString])

Or better, for testing purposes:

Do ilMasterList.$search( pos('b',low($ref.CB_SPEC))>0|pos('b',low(($ref.CB_COMM))>0|pos('b',low(($ref.CB_NAME))>0|pos('b',low(($ref.CB2_
> CER))>0|pos('b',low(($ref.CB_MAST))>0 )

You might want to try this out when fully written out as code, to see if this works as you expect before you put the search pattern in a variable and use this variable in your search string using square brackets.

If you are not working with nulls, you could also change your search pattern to

Do ilMasterList.$search(kFalse)
If ilMasterList.$search(
strpbrk($ref.CB_SPEC,"bB")<>''&strpbrk($ref.COMM,"bB")<>''&strpbrk($ref.CB_NAME,"bB")<>''&strpbrk($ref.CB2_CER,"bB")<>''&strpbrk($ref.CB_MAST,"bB")<>''
) > 0
  ;; Then I have found some lines
End If

as long as you are sure not to have NULL values in the data. Not sure if this is faster though. It is, in my opinion, a little easier to read.

Regards

Rudolf Bargholz

-----Ursprüngliche Nachricht-----
Von: omnisdev-en <omnisdev-en-bounces at lists.omnis-dev.com> Im Auftrag von Das Goravani
Gesendet: Samstag, 31. Dezember 2022 19:49
An: OmnisDev List - English <omnisdev-en at lists.omnis-dev.com>
Betreff: Re: Searches of a list

Method 1
Do ilMasterList.$search([icSearchString])

Method 2
Set current list ilMasterList
Set search as calculation {[icSearchString]} Search list (From start,Select matches (OR),Deselect non-matches (AND),Do not load line)

Neither of the above two approaches works to select lines in the list

> On Dec 31, 2022, at 1:40 PM, Das Goravani <goravanis at gmail.com> wrote:
> 
> 
> I am doing a search of a list in Studio 4 on Windows
> 
> I cannot get it to search my list. Examining it after this executes, there are no "S"s on the list lines when you examine the contents of the variable. I have tried my list.$search() and Set search as calculation way. 
> 
> Is this a valid list search for "Set search as calculation"
> 
> pos('b',low(ilMasterList.CB_SPEC))>0|pos('b',low(ilMasterList.CB_COMM)
> )>0|pos('b',low(ilMasterList.CB_NAME))>0|pos('b',low(ilMasterList.CB2_
> CER))>0|pos('b',low(ilMasterList.CB_MAST))>0
> 
> It’s just the same thing over 5 times… if the search string, in this 
> case letter b, is in any one of the 5 fields, then select this line
> 
> And when you use Set Search as Calculation with a VAR containing your search, do you use square brackets?
> 
> Ie
> 
> Set search as calculation [mySearchString]
> 
> Or do you NOT use square brackets in that case.
> 
> Do you think this should work
> 
> Do myList.$search( [mySearchString] )

_____________________________________________________________
Manage your list subscriptions at https://lists.omnis-dev.com Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 


More information about the omnisdev-en mailing list