update the code to match search of function

This commit is contained in:
YuCheng Hu 2024-01-06 22:24:12 -05:00
parent 4e8be09732
commit 7cf7beb8f6
1 changed files with 22 additions and 17 deletions

View File

@ -1,25 +1,30 @@
; https://www.isharkfly.com/t/mumps-name-search/15226 ; https://www.isharkfly.com/t/mumps-name-search/15226
SET array(1)="Sally" SET nameAry("ALGEBRA,B B")=1
SET array(2)="John" SET nameAry("ALGEBRA,B B")=1
SET array(3)="Tom" SET nameAry("LOB,B B")=1
SET array(4)="Carrie" SET nameAry("LOBLAW,BOB B")=1
SET array(5)="Tomcat" SET nameAry("ZEBRA,B B")=1
SET search ="t" ;SET nameAry(3)="Tom"
DO findNames(search,.array,.matches) ;SET nameAry(4)="Carrie"
;SET nameAry(5)="Tomcat"
;SET nameAry ="t"
S search="LOB"
DO findNames(search,.nameAry,.matches)
SET name="" SET name=""
;f s name=$O(array(name)) q:name="" w !,array(name) ;f s name=$O(array(name)) q:name="" w !,array(name)
f s name=$O(matches(name)) q:name="" w !,name f s name=$O(matches(name)) q:name="" w !,name
QUIT QUIT
findNames(search,nameAry,matches) findNames(search,nameAry,matches)
SET search=$$up(search) n name
SET name="" n matchCount
FOR { S search=$$up(search)
SET name=$O(nameAry(name)) S name=""
QUIT:name="" S matchCount=0
If ($FIND($$up(nameAry(name)),search)> 0) { FOR SET name=$O(nameAry(name)) Q:name="" D
SET matches(nameAry(name))=nameAry(name) . If ($FIND($$up(name),search)>0) D
} . . S matches(name)=nameAry(name)
} . . S matchCount=matchCount+nameAry(name)
QUIT w !,matchCount
QUIT matchCount
up(str) up(str)
QUIT $TRANSLATE(str,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ") QUIT $TRANSLATE(str,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")