View previous topic :: View next topic
|
Author |
Message |
Aravind Kumar. S
New User
Joined: 28 Apr 2005 Posts: 26
|
|
|
|
Hi,
I want to delete the embedded spaces in a string. plz. tell me how to do that .
Thanks,
Aravind. S |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Hi Aravind,
It will be better if you can give an I/P & O/P string.
Regards,
Priyesh. |
|
Back to top |
|
|
Aravind Kumar. S
New User
Joined: 28 Apr 2005 Posts: 26
|
|
|
|
hI Priyesh,
can u explain me in detail.
Thanks,
Aravind |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
You want to delete embedded Spaces....... means the spaces are located at specific position or.......... whereever see two contiguous spaces we have to delete them......
For example you can give your Input String & Output String ....
Regards,
Priyesh. |
|
Back to top |
|
|
Aravind Kumar. S
New User
Joined: 28 Apr 2005 Posts: 26
|
|
|
|
Hi,
Thanks for ur reply.
here's another scenario,
Search string = abcd
IN-STRING = memberabcd
I want to Compare first character of Search string with the characters in IN-STRING until match is found.
If a character is matching, then read the next character in Search string and compare it with the character following the matching character in IN-STRING.
If end of the field in-string is reached and no matching character found display errror.
plz help me to get the solution.
Thanks,
Aravind |
|
Back to top |
|
|
Aravind Kumar. S
New User
Joined: 28 Apr 2005 Posts: 26
|
|
|
|
Hi,
Thanks for ur reply.
here's another scenario,
Search string = abcd
IN-STRING = memberabcd
I want to Compare first character of Search string with the characters in IN-STRING until match is found.
If a character is matching, then read the next character in Search string and compare it with the character following the matching character in IN-STRING.
If end of the field in-string is reached and no matching character found display errror.
plz help me to get the solution.
Thanks,
Aravind |
|
Back to top |
|
|
Aravind Kumar. S
New User
Joined: 28 Apr 2005 Posts: 26
|
|
|
|
hi,
regarding that deletion,
input string - main f r ames
o/p string - mainframes (delete all the spaces in between the string)
Thanks,
Aravind |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Quote: |
here's another scenario,
Search string = abcd
IN-STRING = memberabcd
I want to Compare first character of Search string with the characters in IN-STRING until match is found.
If a character is matching, then read the next character in Search string and compare it with the character following the matching character in IN-STRING.
If end of the field in-string is reached and no matching character found display errror. |
Firstly You should have started a new seperate post for this query....As currently two queries are going in this single post.
Well, for this one I'll not write Code, but will give you an idea to go ahead.
Code: |
PERFORM PROCESS UNTILL STR-FILE-END.
PROCESS.
MOVE ZERO TO A
READ STR-FILE INTO STR-REC.
INSPECT STR-REC TALLYING I FOR CHARACTERS BEFORE ' '.
READ CMP-FILE INTO CMP-REC.
INSPECT CMP-REC TALLYING J FOR CHARACTERS BEFORE ' '.
EXIT.
PERFORM COMPARE J TIMES.
COMPARE.
IF A=J
DISPLAY 'NOT MATCHED'
ELSE
ADD 1 TO A.
IF STR-REC = CMP-REC(A:I)
DISPLAY 'RECORD MATCHED'
END-IF.
EXIT. |
You may need to format the code before running, as its a rough sketch.
Regards,
Priyesh. |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
For above code...
PERFORM COMPARE J TIMES. ....this line will be in PROCESS PARA.
Regards,
Priyesh. |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
I think this was the original query for what this post was intended...Well....
Quote: |
hi,
regarding that deletion,
input string - main f r ames
o/p string - mainframes (delete all the spaces in between the string) |
Code: |
MOVE 'MAIN F RAME' TO WS-XY.
INSPECT WS-XY TALLYING I FOR CHARACTERS BEFORE ' '.
DISPLAY 'LENGTH 'I.
PERFORM MATCH I TIMES.
DISPLAY 'O/P 'WS-YZ.
MATCH.
IF WS-XY(K:1) NOT = ' '
MOVE WS-XY(K:1) TO WS-YZ(Z:1)
ADD 1 TO K Z
ELSE
ADD 1 TO K.
EXIT. |
Arvind, Its not very difficult to bend these stmts acc to your requirements.......the only need is to understand the concept of INSPECT, STRING, UNSTRING verb........
I'll suggest you to go thru thses verbs thoroughly....& then try urself for these queries........You wont find it too difficult......
Regards,
Priyesh. |
|
Back to top |
|
|
shobam
New User
Joined: 18 Jul 2005 Posts: 34 Location: CN
|
|
|
|
Hi,
Sorry for the late reply. There is a option called REPLACE in INSPECT.
Did you try that for the removal of spaces in a string.
INSPECT variable REPLACING ALL " " BY ""
Please correct me if I am wrong.
Thanks & Regards
Shobam |
|
Back to top |
|
|
|