Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing a whole word from lowercase to uppercase.

Status
Not open for further replies.

beginnercobol

Programmer
Feb 20, 2008
2
US
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.
 
How do you know that it's not working?

Is it possible that you are looking for results in the wrong place? The "TITLE-DESCRIPTION OF WS-AREA" implies that there is likely a TITLE-DESCRIPTION field in another area. Are you sure you are looking at the right one?

Code what you mean,
and mean what you code!
But by all means post your code!

Razalas
 
I think only the first inspect will be generated because:

1. all "i" now becomes "I"
2. it will not find "ii" because of #1.
3. it will not find "iii" either because of #1
4. it will not find "iv" because "iv" is now "Iv".

As for #1 all "i" found within a word will be replaced by "I".

Sometimes "i" could really mean "I" or me. So are you
referring "i" as a roman numeral or as a character?
 
It looks like you'll wind up w/edItor I, for example.
e
You didn't mentionn the Compiler version, etc. The later versions of IBM COBOL have intrinsic functions that change case. You should isolate the Romans and return the after case conversion.

Regards, Jack.

"A problem well stated is a problem half solved" -- Charles F. Kettering
 
All,
Unless I am mistaken beginnercobol has added a space before and after the character(s) he is attempting to change. It's difficult to spot, but I'm fairly sure it's there, which means that he should not get 'editor' changed to 'edItor' and that jmanj post also does not apply.

Beginnercobol, if you are still in the building, please confirm that there is a space before and after the required change character in the INSPECT statement.

If there is, then we are left with the 2 scenarios touched upon by Webrabbit and razalas. Webrabbit questions the size of the field and it could be that the size does not allow a space after the 'i', but as 'ii' is allowed, this seems unlikely.

I think that razalas' idea is most likely, and that BC is possibly not looking in the correct place for the answer.

In order to debug this properly, before the INSPECT statement, issue the command:
DISPLAY '@' TITLE-DESCRIPTION OF WS-AREA '@'
followed immediately after the INSPECT with:
DISPLAY '#' TITLE-DESCRIPTION OF WS-AREA '#'

You may have to play with the DISPLAY command according to your compiler and operating system, but you should get a before and an after image of the field, enclosed in @ and #, that you are attempting to change.

Please come back to us beginnercobol and let us know how you get on.

Marc
 
I cut and pasted the original text into a text editor with a mono-spaced font, and there is indeed a space before and after each string.

beginnercobol, please come back into the building.
 
Thanks everyone for all the suggestions. The problem was not with my code, but where I had the code within my program. I had the code in a paragraph that was reading the title letter by letter, so it was not recognizing the roman numerals as a whole. After moving the code to another paragraph, the code works great. Thanks again for everyones help.
 
what about

INSPECT YOUR-IDENTIFIER REPLACING "abcdefghijklmnopqrstuvwxyz" BY "ABCDEFGHIJKLMNOPQRSTUVWXYZ
 
joepiemeloenie,

How about a format 4 inspect;

INSPECT YOUR-IDENTIFIER CONVERTING
"abcdefghijklmnopqrstuvwxyz" TO
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"



Steve
 
You all do realize that the problem of the OP was solved?

Thanks everyone for all the suggestions. The problem was not with my code, but where I had the code within my program.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top