View previous topic :: View next topic
|
Author |
Message |
rohit jaiswal Warnings : 2 New User
Joined: 09 Mar 2006 Posts: 36 Location: hyderabad,A.P
|
|
|
|
I have a requirement where I need to check for the occurence of a lower case letter in any position in a 25 byte field.
I tried it using inspect but it is converting it into upper case from lower and also tried using the hex values for lower case with inspect but it didn't work.
Regards
Rohit |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
is it that you want to check whether atleast one lower char is present ??
do you need the position ??? do you need which character is that ??
if there are more than 1 lower case then ?? |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
depending upon your verison of cobol, you can do several things, but I normally generate 88 levels attatched to a pic x(01) that I float thru the field with an index (you can use a subscript if you don't care about efficiency). The 88 levels I define as either x'....' range or if some idiot has already caused the source program to be upper and lower case - caps off as apposed to caps on, then I set it up as ranges
'a' thru 'i', 'j' thru 'r', 's' thru 'z'.
you can also use class condition.
If I have to enter lower case letters, I put it into a copybook so that I can keep my source program CAPS ON. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Issue an in-line PERFORM and check each byte using ALPHABETIC-LOWER and then save each position in a position-array for each lower-case character found.
The position-array should be large enough to house the number of bytes associated with the target field, with each position defined as a binary-halfword (2 bytes).
Bill |
|
Back to top |
|
|
rohit jaiswal Warnings : 2 New User
Joined: 09 Mar 2006 Posts: 36 Location: hyderabad,A.P
|
|
|
|
Hi Ashimer
I just want to know whethere there is a lower case letter in it or not thats it and i m not concerned abt the position. even if it is one then its fine with me, if i get so then i need to convert it into upper case which i can do using inspect. |
|
Back to top |
|
|
rohit jaiswal Warnings : 2 New User
Joined: 09 Mar 2006 Posts: 36 Location: hyderabad,A.P
|
|
|
|
hi Bill O'Boyle
can u provide me with more information on the alphabetic-lower function.
regards
rohit |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
APLHABETIC-LOWER is a class condition not a function and is covered in the COBOL Language Reference for the version of COBOL you are using. |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
You can do this couple of ways ...
Code: |
01 ws-name pic x(25) value 'AsHIMER'.
01 ws-count pic s9(4) comp value 1.
01 ws-alpha PIC X(01).
88 ws-lower VALUE 'a' thru 'z'.
perform until ws-count >= length of ws-name
or ws-lower
move ws-name(ws-count:1) to ws-alpha
if ws-lower
then display 'lower char present'
display 'position=' ws-count
exit
end-if
compute ws-count = ws-count + 1
end-perform
|
and
Code: |
inspect ws-name converting
"abcdefghijklmnopqrstuvwxyz"
to
"@@@@@@@@@@@@@@@@@@@@@@@@@@"
inspect ws-name tallying ws-count for '@'
if ws-count > 0 then
lower char present
end-if
|
|
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
I beg to remind everyone that the english alphabet is not one (1) range but 3:
'a' thru 'i', 'j' thru 'r', 's' thru 'z'. whether upper or lower. the ranges between i and j and r and s are not a part of the english alphabet. |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
Thanks for that Dick. I really appreciate. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
rohit jaiswal wrote: |
Hi Ashimer
I just want to know whethere there is a lower case letter in it or not thats it and i m not concerned abt the position. even if it is one then its fine with me, if i get so then i need to convert it into upper case which i can do using inspect. |
Anyways you are going to convert that charactar to upper case, then why look for it?
directly use function UPPER-CASE or INSPECT on that field? Let me know if I misinterpreted your requirement. |
|
Back to top |
|
|
rohit jaiswal Warnings : 2 New User
Joined: 09 Mar 2006 Posts: 36 Location: hyderabad,A.P
|
|
|
|
Hi All
Thanks for the quick response and the solutions in solving my problem, i have ran the job and getting the perfect output.
Regards
rohit |
|
Back to top |
|
|
ashimer
Active Member
Joined: 13 Feb 2004 Posts: 551 Location: Bangalore
|
|
|
|
Cool |
|
Back to top |
|
|
|