From 772563ed6a25b7ea090d33ad0344c2f7796fa752 Mon Sep 17 00:00:00 2001 From: YuCheng Hu Date: Fri, 5 Jan 2024 23:59:00 -0500 Subject: [PATCH] init submit sort function --- routines/SortingNames.m | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 routines/SortingNames.m diff --git a/routines/SortingNames.m b/routines/SortingNames.m new file mode 100644 index 0000000..0c557fc --- /dev/null +++ b/routines/SortingNames.m @@ -0,0 +1,23 @@ + ; https://www.isharkfly.com/t/mumps-sorting-names/15225 + new name + set name=$$getName() + if name="" quit + write !,"You entered: ",name + DO validateAndAddName(name, .nameAry) + set name="" + f s name=$O(nameAry(name)) q:name="" w !,nameAry(name) + quit +validateAndAddName(name,nameAry) + SET nameAry(0)=name +getName() new name,done,error + for read !,"Enter a name (LAST,FIRST MI):",name quit:name="" do quit:done + . set done=$$isValidName(.name,.error) + . if 'done write !,error + quit name +isValidName(name,error) + set name=$$up(name) + if name'?1.U1",".1" "1.U.1(1" "1U) set error="Invalid name" quit 0 + quit 1 + ;validateAndAddName(name,nameAry) +up(str) + quit $TRANSLATE(str,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")