View previous topic :: View next topic
|
Author |
Message |
adarsh444
New User
Joined: 02 Nov 2006 Posts: 17
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
adarsh444
New User
Joined: 02 Nov 2006 Posts: 17
|
|
|
|
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 |
|
|
David P
Active User
Joined: 11 Apr 2005 Posts: 106 Location: Cincinnati Ohio
|
|
|
|
I believe IN LINE PERFORM sould do what you want.
David P. |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
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 |
|
|
Pallavi_khopkar
New User
Joined: 01 Apr 2006 Posts: 6
|
|
|
|
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 |
|
|
|