IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

CHecking for lower case in a string


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rohit jaiswal
Warnings : 2

New User


Joined: 09 Mar 2006
Posts: 36
Location: hyderabad,A.P

PostPosted: Tue Jul 15, 2008 7:50 pm
Reply with quote

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
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Tue Jul 15, 2008 8:33 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Jul 15, 2008 8:39 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Jul 15, 2008 9:24 pm
Reply with quote

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
View user's profile Send private message
rohit jaiswal
Warnings : 2

New User


Joined: 09 Mar 2006
Posts: 36
Location: hyderabad,A.P

PostPosted: Wed Jul 16, 2008 6:26 pm
Reply with quote

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
View user's profile Send private message
rohit jaiswal
Warnings : 2

New User


Joined: 09 Mar 2006
Posts: 36
Location: hyderabad,A.P

PostPosted: Wed Jul 16, 2008 6:31 pm
Reply with quote

hi Bill O'Boyle

can u provide me with more information on the alphabetic-lower function.

regards
rohit
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Wed Jul 16, 2008 6:53 pm
Reply with quote

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
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Wed Jul 16, 2008 6:54 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jul 16, 2008 7:30 pm
Reply with quote

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
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Wed Jul 16, 2008 7:40 pm
Reply with quote

Thanks for that Dick. I really appreciate.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Wed Jul 16, 2008 8:11 pm
Reply with quote

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
View user's profile Send private message
rohit jaiswal
Warnings : 2

New User


Joined: 09 Mar 2006
Posts: 36
Location: hyderabad,A.P

PostPosted: Thu Jul 17, 2008 7:01 pm
Reply with quote

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
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Thu Jul 17, 2008 7:03 pm
Reply with quote

Cool icon_cool.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Copy only TEXT or String from a record SYNCSORT 4
No new posts ICETOOL to SUM String DFSORT/ICETOOL 1
No new posts Mark Previous & next lines when a... DFSORT/ICETOOL 9
No new posts sort to find out the char which repea... Mainframe Interview Questions 10
No new posts Help with C character vs C string All Other Mainframe Topics 3
Search our Forums:

Back to Top