init submit Name Search function

This commit is contained in:
YuCheng Hu 2024-01-06 00:40:09 -05:00
parent 772563ed6a
commit 4e8be09732
1 changed files with 25 additions and 0 deletions

25
routines/NameSearch.m Normal file
View File

@ -0,0 +1,25 @@
; 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 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
up(str)
QUIT $TRANSLATE(str,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")