From 4e8be09732ca938b91b78e4c5250257402d75b53 Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Sat, 6 Jan 2024 00:40:09 -0500 Subject: [PATCH] init submit Name Search function --- routines/NameSearch.m | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 routines/NameSearch.m diff --git a/routines/NameSearch.m b/routines/NameSearch.m new file mode 100644 index 0000000..68f8c3f --- /dev/null +++ b/routines/NameSearch.m @@ -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")