init submit sort function

This commit is contained in:
YuCheng Hu 2024-01-05 23:59:00 -05:00
parent eb9c98ae88
commit 772563ed6a
1 changed files with 23 additions and 0 deletions

23
routines/SortingNames.m Normal file
View File

@ -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")