Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Checking each letter in the string X(10)

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
adarsh444

New User


Joined: 02 Nov 2006
Posts: 17

PostPosted: Tue Nov 21, 2006 11:28 pm    Post subject: Checking each letter in the string X(10)
Reply with quote

i have code for checking each letter in the string X(10) as shoen below


evaluate true
when string(1:1) = 'A'
string(2:1) = 'A'
.
.
string(10:1) = 'A'
.....
.....
when string(1:1) = 'B'
string(2:1) = 'B'
.
.
string(10:1) = 'B'
.....
.....
.
.
.
.
.
.
when string(1:1) = 'Z'
string(2:1) = 'Z'
.
.
string(10:1) = 'Z'

....
.....
END-EVALUATE



This should be fine but is there any effiecient way to check this
please help me.
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Tue Nov 21, 2006 11:42 pm    Post subject: Re: condition check
Reply with quote

adarsh444 wrote:
i have code for checking each letter in the string X(10)


What are you checking for?

What do you do if successful?
Back to top
View user's profile Send private message
adarsh444

New User


Joined: 02 Nov 2006
Posts: 17

PostPosted: Tue Nov 21, 2006 11:51 pm    Post subject:
Reply with quote

evaluate true
when string(1:1) = 'A'
move ws-string to ws-str-field
...
...

i need to perform this check with minimum code as possible.
Back to top
View user's profile Send private message
David P

Active User


Joined: 11 Apr 2005
Posts: 106
Location: Cincinnati Ohio

PostPosted: Wed Nov 22, 2006 12:01 am    Post subject: Re: condition check
Reply with quote

I believe IN LINE PERFORM sould do what you want.

David P.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Wed Nov 22, 2006 1:02 am    Post subject: Re: condition check
Reply with quote

adarsh...

You mean to say there is a WS-STRING with length of X(10) and you are checking every character from "A" to "Z" and move WS-String to some variable, if condition is satisfied. So in total 26x10 = 260 comparison. Is that the understanding ?

Another thing, if it is a char field, checking for first position itself would take you out of Evaluate check. As it would contain some value between "A" & "Z" then why to code check for other 9 positions. So it'll help, if you can describe more on what is actually you want to check this field in such a way.
Back to top
View user's profile Send private message
Pallavi_khopkar

New User


Joined: 01 Apr 2006
Posts: 6

PostPosted: Mon Nov 27, 2006 2:20 pm    Post subject: Re: Checking each letter in the string X(10)
Reply with quote

You can use the below code.
01 VAR1 PIC X(20) VALUE 'AB485#$%CD'. <- Assumed i/p string
01 VAR1-LEN PIC 9(2).

INSPECT VAR1 TALLYING VAR1-LEN FOR CHARACTERS BEFORE INITIAL SPACE.
J = 1.
PERFORM VARYING I FROM 1 BY 1 UNTIL I > VAR1-LEN
IF VAR1(I:1) >= 'A' AND VAR1(I:1) <= 'Z' THEN
MOVE VAR1(I:1) TO VAR2(J:1)
COMPUTE J = J + 1
END-IF
END-PERFORM.
DISPLAY 'VAR2 = ' VAR2.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts NDM syntax checking without actually ... GAPX1 All Other Mainframe Topics 0 Wed Jun 07, 2017 2:36 am
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts Checking Current date vickey_dw DFSORT/ICETOOL 1 Wed Feb 08, 2017 11:14 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us