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
SET array(1)="Sally"
SET array(2)="John"
SET array(3)="Tom"
SET array(4)="Carrie"
SET array(5)="Tomcat"
SET search ="t"
DO findNames(search,.array,.matches)
SET nameAry("ALGEBRA,B B")=1
SET nameAry("ALGEBRA,B B")=1
SET nameAry("LOB,B B")=1
SET nameAry("LOBLAW,BOB B")=1
SET nameAry("ZEBRA,B B")=1
;SET nameAry(3)="Tom"
;SET nameAry(4)="Carrie"
;SET nameAry(5)="Tomcat"
;SET nameAry ="t"
S search="LOB"
DO findNames(search,.nameAry,.matches)
SET name=""
;f s name=$O(array(name)) q:name="" w !,array(name)
f s name=$O(matches(name)) q:name="" w !,name
QUIT
findNames(search,nameAry,matches)
SET search=$$up(search)
SET name=""
FOR {
SET name=$O(nameAry(name))
QUIT:name=""
If ($FIND($$up(nameAry(name)),search)> 0) {
SET matches(nameAry(name))=nameAry(name)
}
}
QUIT
n name
n matchCount
S search=$$up(search)
S name=""
S matchCount=0
FOR SET name=$O(nameAry(name)) Q:name="" D
. If ($FIND($$up(name),search)>0) D
. . S matches(name)=nameAry(name)
. . S matchCount=matchCount+nameAry(name)
w !,matchCount
QUIT matchCount
up(str)
QUIT $TRANSLATE(str,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")