TechTalk: Case Conversion

General
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

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 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  •  

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: