Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: BMXTRS

BMXTRS.m

Go to the documentation of this file.
BMXTRS ; IHS/OIT/HMW - UPPERCASE-LOWERCASE ;
 ;;4.0;BMX;;JUN 28, 2010
 ;
T(X) ;EP
 ;---> Translate word to mixed case.
 ;
 N BMXWORD,I
 I '$D(X) Q ""
 I X="^" Q X
 I X=" " Q X
 ;-----> REMOVE LEADING INAPPROPRIATE CHARACTERS IF PRESENT.
 F  Q:$E(X)'?1P  S X=$E(X,2,99)
 ;-----> CHANGE FIRST LETTER TO UPPERCASE:
 S BMXWORD=$E(X)
 I $E(BMXWORD)?1L S BMXWORD=$C($A($E(BMXWORD))-32)
 ;-----> DO NEXT CHARACTER
 F I=2:1:$L(X) D CHAR
 ;-----> REMOVE TRAILING SPACE OR QUOTE.
 F  Q:""" "'[$E(BMXWORD,$L(BMXWORD))  D
 .S BMXWORD=$E(BMXWORD,1,($L(BMXWORD)-1))
 ;-----> RESET X EQUAL TO RESULT
EOJ ;
 Q BMXWORD
 ;
CHAR ;
 ;-----> IF THE CHARACTER IS UPPERCASE AND PREVIOUS CHARACTER IS NOT
 ;-----> PUNCTUATION (EXCEPT FOR AN APOSTROPHY) OR A SPACE,
 ;-----> THEN CHANGE CHARACTER TO LOWERCASE:
 I ($E(X,I)?1U)&(($E(X,I-1)'?1P)!($E(X,I-1)="'")) D  Q
 .S BMXWORD=BMXWORD_$C($A($E(X,I))+32)
 ;
 ;-----> IF THE CHARACTER IS LOWERCASE AND PREVIOUS CHARACTER IS
 ;-----> PUNCTUATION (BUT NOT AN APOSTROPHY) OR A SPACE, THEN CHANGE
 ;-----> CHARACTER TO UPPERCASE:
 I $E(X,I)?1L,$E(X,I-1)?1P,$E(X,I-1)'="'" D  Q
 .S BMXWORD=BMXWORD_$C($A($E(X,I))-32)
 ;
 ;-----> ADD CHARACTER TO BMXWORD STRING WITHOUT MODIFICATION.
 ;-----> "\" PLACED BEFORE A LETTER FORCES IT TO BE UPPERCASE;
 ;-----> HERE REMOVE ANY "\"'s.
 I $E(X,I)'="\" S BMXWORD=BMXWORD_$E(X,I)
 Q