With more and more computers talking to each other and exchanging data, the situation of having to convert upper case to upper-lower case, and vice-versa arrises occasionally. Converting lower case to upper case is very easy-you just set on the second bit of each alphabetic character with the following operation:
BITON'1' CHAR 1
Converting from upper to lower case uses the BITOF command:
BITOF'1' CHAR 1
Don't try to convert anything other than alphabetic characters. If you do, you may change a character to something completely different. Converting from upper case to upper-lower case adds more to think about-you must not change the first character of a word to lower case if the word is in a name or address field.
1 shows a sample program that will convert uppercase to upper-lower case for an alphanumeric field within a length of 100. All words or abbreviations will retain an uppercase first character. This program is assuming that the input field has been loaded into array F (100 x 1). The code was created for the S/36 but will work on the S/38 or AS/400. However, S/38 and AS/400 programmers would probably want to make the three IFxx operations into an explicit AND group which would eliminate levels 3 and 4 of the logic.
Figure 1 shows a sample program that will convert uppercase to upper-lower case for an alphanumeric field within a length of 100. All words or abbreviations will retain an uppercase first character. This program is assuming that the input field has been loaded into array F (100 x 1). The code was created for the S/36 but will work on the S/38 or AS/400. However, S/38 and AS/400 programmers would probably want to make the three IFxx operations into an explicit AND group which would eliminate levels 3 and 4 of the logic.
If you want to convert your own files, assess your requirements carefully for any changes or additions to the very basic logic of the sample program.
Midrange Computing Staff
TechTalk: Case Conversion
Figure 1 Upper to lower case conversion program
C* C* Converts all upper case character string to upper-lower case C* C* Input is array F (100 x 1) which is loaded with field to be converted C* C 2 DO 100 A 30 C A SUB 1 B 30 C* C* If previous character was not blank and this character is uppercase C* A-Z, then make it lowercase C* C F,B IFNE ' ' C F,A IFGE 'A' C F,A IFLE 'Z' C BITOF'1' F,A C END C END C END C END
LATEST COMMENTS
MC Press Online