From 7cf7beb8f66cd5e05ee888e3a6c21f6f517f6015 Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Sat, 6 Jan 2024 22:24:12 -0500 Subject: [PATCH] update the code to match search of function --- routines/NameSearch.m | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/routines/NameSearch.m b/routines/NameSearch.m index 68f8c3f..8c3f4fa 100644 --- a/routines/NameSearch.m +++ b/routines/NameSearch.m @@ -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")