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

LEXXM1.m

Go to the documentation of this file.
LEXXM1 ;ISL/KER - Convert Text to Mix Case (1) ;12/19/2014
 ;;2.0;General Lexicon Utilities;**80,86**;Sep 23, 1996;Build 1
 ;               
 ; Global Variables
 ;    None
 ;               
 ; External References
 ;    None
 ;               
 ; Local Variables NEWed or KILLed Elsewhere
 ;     LEXNXT,LEXUSE
 ;     
T1 ; 1 Character
 N XU,CHR,PRE,LEXPRE,UIN,NXT,USE S PRE=$G(LEXPRE),UIN=$G(UIN),NXT=$G(LEXNXT),USE=$G(LEXUSE) S XU=$$UP(X),CHR=$E(XU,1)
 S:XU="W"&(($G(UIN)["W/WO")!($G(UIN)["W/")) Y=$$LO(XU) Q:$L($G(Y))
 ;   Special Case "A"
 S Y="" I XU="A",$E(NXT,1,7)["SINGLE" S Y=$$LO(XU) Q
 I $D(UIN),"^A^"[("^"_XU_"^"),(" "_UIN_" ")[(" "_XU_" ") D  Q:$L($G(Y))
 . N UP S Y=XU Q:UIN[" A OR V "  Q:UIN[" T AND A "  Q:UIN[" A & E"  Q:UIN[" A OR B"  Q:UIN["O>HM< A"  S UP=$$UPA(XU,PRE,UIN) S:+UP'>0 Y=$$LO(XU)
 ;   Special Case W/O
 I "^O^W^"[("^"_XU_"^")&(UIN["W/O") S Y=$$LO(XU) Q
 I "^G^"[("^"_XU_"^")&(+($G(PRE))>0) S Y=$$LO(XU) Q
 ;   Uppercase
 I "^B^C^D^E^F^G^H^I^J^K^L^M^N^O^P^Q^R^S^T^U^V^X^Y^Z^"[("^"_XU_"^") S Y=XU Q
 Q
 ;            
UPA(X,Y,Z) ; Check if "A" is Uppercase A
 N CHR,FIR,OK,PRE,UP,W,XU
 S XU=$G(X),PRE=$G(Y),UIN=$G(Z),FIR=$A($E(PRE,1))
 S OK=1 Q:UIN[" A OR V " 1  Q:UIN[" T and A " 1  Q:UIN[" A & E" 1  Q:UIN[" A OR B" 1  Q:UIN["O>HM< A" 1  Q:PRE="&" 1
 S OK=0 I FIR<66 F W="ACETYLGLUCOSAMINIDASE","ACETYLHEXOSAMINIDASE","ACTIONS","ACTIVIN","ACYLCOENZYME","AKIYAMI","ALDOLASE","AMINOPEPTIDASE" S:PRE=W OK=1
 Q:OK=1 1  I FIR<66 F W="AMPHOTERICIN","AMYLOID","ANOPHELES","ANTI","ANTIBODY","ANTIGEN","APHTHOVIRUS","APOLIPOPROTEIN","APOLIPOPROTEINS","ARYLSULFATASE" S:PRE=W OK=1
 Q:OK=1 1  I FIR<68 F W="ATTRIBUTE","ATTRIBUTES","AUXIN","AZURE","BACITRACIN","BIOVAR","BISPHENOL","BOTULINIUM","BOTULINUM","CARBOMYCIN","CARBOXYPEPTIDASE" S:PRE=W OK=1
 Q:OK=1 1  I FIR>66,FIR<68 F W="CARMOISINE","CAROTID","CATEGORY","CHROMOGRANIN","CHYMOTRYPSIN","CICLOSPORIN","CLASS","CLINIC","CLUSTER","COBALAMIN","COENZYME" S:PRE=W OK=1
 Q:OK=1 1  I FIR>66,FIR<70 F W="COMPOUND","CON","CONCANAVALIN","CORONARY","COXSACKIE","COXSACKIEVIRUS","CYCLOSPORIN","DIPEPTIDASE","DNASE","DOUBLE","ENTEROTOXIN" S:PRE=W OK=1
 Q:OK=1 1  I FIR>68,FIR<72 F W="ENZYMES","EQUIZOLE","FEEDS","FIBRINOPEPTIDE","FIBRINOPEPTIDES","FORMULA","GALACTOSIDASE","GELATINASE","GENUS","GLYCOPHORIN","GP" S:PRE=W OK=1
 Q:OK=1 1  I FIR>70,FIR<73 F W="GRADE","GRANZYME","GROUP","HAEMOGLOBIN","HAEMOPHILIA","HB","HEMOGLOBIN","HEMOPHILIA","HEP","HEPATITIS","HEXOSAMINIDASE","HLA","HPFH" S:PRE=W OK=1
 Q:OK=1 1  I FIR>71,FIR<74 F W="HYPERVITAMINOSIS","HYPOGLYCIN","HYPOVITAMINOSIS","I","II","III","IMMUNOGLOBULIN","INDEX","INFLUENZA","INFLUENZAE","INFLUENZAVIRUS" S:PRE=W OK=1
 Q:OK=1 1  I FIR>72,FIR<78 F W="INHIBIN","IV","JEC","LANTADENE","LASALOCID","LEFT","LEPROMIN","LEUKOTRIENE","LEVEL","LIPOPROTEIN","LOCUS","MED","MENINGITIDIS" S:PRE=W OK=1
 Q:OK=1 1  I FIR>76,FIR<80 F W="MENINGITIS","MEPRIN","MOENOMYCIN","MORQUIO","NEOVITAMIN","NEUROKININ","NUTRITION","OLEOVITAMIN","OLIGOPEPTIDASE","ORBITAL","OXIDASE" S:PRE=W OK=1
 Q:OK=1 1  I FIR>79,FIR<81 F W="PADIMATE","PARATYPHI","PARATYPHOID","PEPSIN","PHOSPHOLIPASE","POLYSACCHARIDE","PRECURSORS","PROTEIN","PROTEINASE","PROTEINS" S:PRE=W OK=1
 Q:OK=1 1  I FIR>79,FIR<84 F W="PROTOVERATRINE","PUMILIOTOXIN","RASTELLI","RH","RHINITIS","RIGHT","RUTTER","SCILLAREN","SCYTALIDOPEPSIN","SEROTYPE","SOLVENT" S:PRE=W OK=1
 Q:OK=1 1  I FIR>82,FIR<85 F W="SOMATOMEDIN","SPECIES","STAGE","STREPTOGRISIN","SUBGROUP","SUBSCALE","SUBUNIT","SULFATASE","SULFATE","SULPHATASE","T","TARIFF" S:PRE=W OK=1
 Q:OK=1 1  I FIR>83,FIR<91 F W="TOXIN","TRIPLE","TYPE","TYPING","ULTRAVIOLET","VALUES","VENOMBIN","VIRUS","VITAMIN","WEAK" S:PRE=W OK=1
 S X=OK
 Q X
 ;                    
LO(X) ; Lower Case
 Q $TR(X,"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")
UP(X) ; Uppercase
 Q $TR(X,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")
MX(X) ; Mix Case
 Q $TR($E(X,1),"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ")_$TR($E(X,2,$L(X)),"ABCDEFGHIJKLMNOPQRSTUVWXYZ","abcdefghijklmnopqrstuvwxyz")
TRIM(X) ; Trim Spaces
 S X=$G(X) F  Q:$E(X,1)'=" "  S X=$E(X,2,$L(X))
 F  Q:$E(X,$L(X))'=" "  S X=$E(X,1,($L(X)-1))
 N LEXNXT,LEXUSE
 Q X