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

Checking each letter in the string X(10)


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 3156
Location: Tucson AZ

PostPosted: Tue Nov 21, 2006 11:42 pm
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
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
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: 1448
Location: Chicago, IL

PostPosted: Wed Nov 22, 2006 1:02 am
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts file manager is doing string conversion IBM Tools 3
No new posts Search string in job at regular Spool... CLIST & REXX 0
Search our Forums:

Back to Top