Changing part of a word from lowercase to uppercase.



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Changing part of a word from lowercase to uppercase.

Postby cobolbeginner » Wed Feb 20, 2008 10:50 pm

I am trying to change the roman numerals in a person's job title from lowercase to uppercase. For example, the following titles editor i, editor ii, and editor iii need to be changed to editor I, editor II, and editor III. I tried an inspect statement but it is not doing it. Here's the inspect statement that I tried.

INSPECT TITLE-DESCRIPTION OF WS-AREA REPLACING ALL
' i ' BY ' I '.
INSPECT TITLE-DESCRIPTION OF WS-AREA REPLACING ALL
' ii ' BY ' II '.
INSPECT TITLE-DESCRIPTION OF WS-AREA REPLACING ALL
' iii ' BY ' III '.
INSPECT TITLE-DESCRIPTION OF WS-AREA REPLACING ALL
' iv ' BY ' IV '.

Any suggestions would be greatly appreciated. Thanks.
cobolbeginner
 
Posts: 3
Joined: Wed Feb 20, 2008 10:47 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Changing part of a word from lowercase to uppercase.

 

Re: Changing part of a word from lowercase to uppercase.

Postby dick scherrer » Wed Feb 20, 2008 11:17 pm

Hello CB and welcome to the forums,

I tried an inspect statement but it is not doing it.
When something doesn't work as desired, you need to post either the error (if any) or the undesired result. Your post does not describe your problem.

Also, when you post code, it makes your post much more readable if you use the "Code" tab near the top of the reply panel.

If you use the Preview (next to Submit), you can ensure your post appears as you want it and when your are satisfied with the reply, click Submit.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Changing part of a word from lowercase to uppercase.

Postby cobolbeginner » Thu Feb 21, 2008 3:23 am

Sorry for the improper post. I'm new at this stuff. What I need my code to do is look at the job title. If the title has a roman numeral in it, the roman numeral needs to be uppercase. Okay, so now I've ran my program again with the inspect statement. Following is the code that I have in my program:
INSPECT TITLE-DESCRIPTION OF WS-AREA2
REPLACING ALL ' i ' BY ' I '.         
INSPECT TITLE-DESCRIPTION OF WS-AREA2
REPLACING ALL ' ii ' BY ' II '.       
INSPECT TITLE-DESCRIPTION OF WS-AREA2
REPLACING ALL ' iii ' BY ' III '.     
INSPECT TITLE-DESCRIPTION OF WS-AREA2
REPLACING ALL ' iv ' BY ' IV '.       


Here are the titles before running my program:
staff attorney ii
printing services tech iii
data entry operator iii
printing services tech iii
computer info tech spec ii
budget research analyst ii

Here are the results that I am getting after:
staff attorney II
printing services tech Iii
data entry operator Iii
printing services tech Iii
computer Info tech spec Ii
budget research analyst II

Notice that the code appears to have worked on the first and last item, but on the items in the middle, it only made the first 'i' uppercase. Also notice that in the computer Info tech spec Ii the 'I' on Info was made uppercase. Any suggestions as to what I might be doing wrong? I hope this is a little easier to read. Any help is greatly appreciated.
cobolbeginner
 
Posts: 3
Joined: Wed Feb 20, 2008 10:47 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Changing part of a word from lowercase to uppercase.

Postby dick scherrer » Thu Feb 21, 2008 4:18 am

Hello,

Sorry for the improper post. I'm new at this stuff.
Not to worry :)

The following code (with the inspect values inverted or not) works on one of my systems. . .

       01  WS-A PIC X(29) VALUE SPACES.

           MOVE 'staff attorney ii' TO WS-A.                   
           INSPECT WS-A REPLACING ALL ' iv ' BY ' IV '.       
           INSPECT WS-A REPLACING ALL ' iii ' BY ' III '.     
           INSPECT WS-A REPLACING ALL ' ii ' BY ' II '.       
           INSPECT WS-A REPLACING ALL ' i ' BY ' I '.         
           DISPLAY WS-A.                                       
           MOVE 'data entry operator ii' TO WS-A.             
           INSPECT WS-A REPLACING ALL ' iv ' BY ' IV '.       
           INSPECT WS-A REPLACING ALL ' iii ' BY ' III '.     
           INSPECT WS-A REPLACING ALL ' ii ' BY ' II '.       
           INSPECT WS-A REPLACING ALL ' i ' BY ' I '.         
           DISPLAY WS-A.                                       
           MOVE 'computer info tech ii' TO WS-A.               
           INSPECT WS-A REPLACING ALL ' i ' BY ' I '.         
           INSPECT WS-A REPLACING ALL ' ii ' BY ' II '.       
           INSPECT WS-A REPLACING ALL ' iii ' BY ' III '.     
           INSPECT WS-A REPLACING ALL ' iv ' BY ' IV '.       
           DISPLAY WS-A.                                         
           MOVE 'computer info tech iii  ' TO WS-A.             
           INSPECT WS-A REPLACING ALL ' i ' BY ' I '.           
           INSPECT WS-A REPLACING ALL ' ii ' BY ' II '.         
           INSPECT WS-A REPLACING ALL ' iii ' BY ' III '.       
           INSPECT WS-A REPLACING ALL ' iv ' BY ' IV '.         
           DISPLAY WS-A.                                         
           GOBACK.             

results:
staff attorney II         
data entry operator II   
computer info tech II     
computer info tech III   


Which compiler are you using?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Changing part of a word from lowercase to uppercase.

Postby cobolbeginner » Fri Feb 22, 2008 12:22 am

Thanks for your help. After having a co-worker look at my program the inspect statement worked fine when I moved it out of the paragragh I had it in. It was in a paragraph with a single character loop, so my inspect statement was looking at each individual letter and not the word as a whole. It now performs the action I need it to perform. Thanks again! :D
cobolbeginner
 
Posts: 3
Joined: Wed Feb 20, 2008 10:47 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Changing part of a word from lowercase to uppercase.

Postby dick scherrer » Fri Feb 22, 2008 12:28 am

Good to hear it is working.

Thanks for posting the resolution :)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post