source: BMXNET_RPMS_dotNET_UTILITIES-BMX/trunk/m/BMXTRS.m@ 1489

Last change on this file since 1489 was 1209, checked in by Sam Habiel, 13 years ago

BMXMON fix; updated all routines to v 2.31

File size: 1.3 KB
RevLine 
[645]1BMXTRS ; IHS/OIT/HMW - UPPERCASE-LOWERCASE ;
[1209]2 ;;2.31;BMX;;Jul 25, 2011
[645]3 ;
4T(X) ;EP
5 ;---> Translate word to mixed case.
6 ;
7 N BMXWORD,I
8 I '$D(X) Q ""
9 I X="^" Q X
10 I X=" " Q X
11 ;-----> REMOVE LEADING INAPPROPRIATE CHARACTERS IF PRESENT.
12 F Q:$E(X)'?1P S X=$E(X,2,99)
13 ;-----> CHANGE FIRST LETTER TO UPPERCASE:
14 S BMXWORD=$E(X)
15 I $E(BMXWORD)?1L S BMXWORD=$C($A($E(BMXWORD))-32)
16 ;-----> DO NEXT CHARACTER
17 F I=2:1:$L(X) D CHAR
18 ;-----> REMOVE TRAILING SPACE OR QUOTE.
19 F Q:""" "'[$E(BMXWORD,$L(BMXWORD)) D
20 .S BMXWORD=$E(BMXWORD,1,($L(BMXWORD)-1))
21 ;-----> RESET X EQUAL TO RESULT
22EOJ ;
23 Q BMXWORD
24 ;
25CHAR ;
26 ;-----> IF THE CHARACTER IS UPPERCASE AND PREVIOUS CHARACTER IS NOT
27 ;-----> PUNCTUATION (EXCEPT FOR AN APOSTROPHY) OR A SPACE,
28 ;-----> THEN CHANGE CHARACTER TO LOWERCASE:
29 I ($E(X,I)?1U)&(($E(X,I-1)'?1P)!($E(X,I-1)="'")) D Q
30 .S BMXWORD=BMXWORD_$C($A($E(X,I))+32)
31 ;
32 ;-----> IF THE CHARACTER IS LOWERCASE AND PREVIOUS CHARACTER IS
33 ;-----> PUNCTUATION (BUT NOT AN APOSTROPHY) OR A SPACE, THEN CHANGE
34 ;-----> CHARACTER TO UPPERCASE:
35 I $E(X,I)?1L,$E(X,I-1)?1P,$E(X,I-1)'="'" D Q
36 .S BMXWORD=BMXWORD_$C($A($E(X,I))-32)
37 ;
38 ;-----> ADD CHARACTER TO BMXWORD STRING WITHOUT MODIFICATION.
39 ;-----> "\" PLACED BEFORE A LETTER FORCES IT TO BE UPPERCASE;
40 ;-----> HERE REMOVE ANY "\"'s.
41 I $E(X,I)'="\" S BMXWORD=BMXWORD_$E(X,I)
42 Q
Note: See TracBrowser for help on using the repository browser.