MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

In between space - PL/1

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
anbesivam
Beginner


Joined: 09 Aug 2006
Posts: 66
Topics: 14

PostPosted: Wed Nov 15, 2006 10:50 am    Post subject: In between space - PL/1 Reply with quote

I am having following requirement.

Code:
The string 'XXX XXXXX' should be changed as 'XXXXXXXX'  --> In between two strings space is removed.


This can be possible through some three or four line of code. But
is there any way to do this using any of the PL/1 builtin function or combination of builtin functons in one line?

Kindly let me know.
Back to top
View user's profile Send private message
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Thu Nov 16, 2006 2:28 am    Post subject: Reply with quote

anbesivam,


Try this code:
Code:

      DCL TRANSLATE BUILTIN;                                           
      DCL X CHAR(09) INIT('XXX XXXXX');                                 
      DCL Y CHAR(09) INIT('XXXXXXXXX');                                 
      DCL Z CHAR(09) INIT('XXX XXXXX');                                 
      DCL Q CHAR(08) INIT(' ');                                         
      Q = TRANSLATE(X,Y,Z);                                             
      PUT SKIP LIST('Q IS:',Q);                                         

Q IS:                   XXXXXXXX

_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message
bauer
Intermediate


Joined: 10 Oct 2003
Posts: 315
Topics: 49
Location: Germany

PostPosted: Thu Nov 16, 2006 4:24 am    Post subject: Reply with quote

Hi all,

my understanding of the question is: Remove any number of Spaces in a string.

So string can be ABC DEF, desired result: ABCDEF.

This doesn't solve the code of shekar123.
Back to top
View user's profile Send private message
anbesivam
Beginner


Joined: 09 Aug 2006
Posts: 66
Topics: 14

PostPosted: Thu Nov 16, 2006 5:27 am    Post subject: Reply with quote

Hi shekar123,

Thanks much for your response.

Your code works fine, if the charecter is 'XXX XXXXX'.

I need to do that for follows

Code:
'THE VALUE' ---> should be changed as 'THEVALUE'.


Is this possible ?
Back to top
View user's profile Send private message
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Thu Nov 16, 2006 5:51 am    Post subject: Reply with quote

anbesivam,

Try this code:

Code:

      DCL TRANSLATE BUILTIN;                                           
      DCL X CHAR(09) INIT('THE VALUE');                                 
      DCL Y CHAR(09) INIT('THEVALUE ');                                 
      DCL Z CHAR(09) INIT('THE VALUE');                                 
      DCL Q CHAR(08) INIT(' ');                                         
      Q = TRANSLATE(X,Y,Z);                                             
      PUT SKIP LIST('Q IS:',Q);                                         

Q IS:                   THEVALUE

_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message
bauer
Intermediate


Joined: 10 Oct 2003
Posts: 315
Topics: 49
Location: Germany

PostPosted: Thu Nov 16, 2006 7:50 am    Post subject: Reply with quote

shekar123,


and I like to do is for

Code:


and i like to do it for

Back to top
View user's profile Send private message
bauer
Intermediate


Joined: 10 Oct 2003
Posts: 315
Topics: 49
Location: Germany

PostPosted: Thu Nov 16, 2006 10:04 am    Post subject: Reply with quote

anbesivam,

if you are talking about to remove only on blank which must exist and you are looking for a solution in one line, try this:

Code:

 DCL X CHAR(10) AUTO INIT('TEST 67890');
 PUT SKIP EDIT(
        SUBSTR(X,1,SEARCH(X,'40'X) - 1)
     || SUBSTR(X,SEARCH(X,'40'X) + 1)
              ) (A) ;



But if you are talking about to remove several blanks I agree with you, that it is necessary to write a small function.

No builtin function is abvailable to remove special bytes from a string.


regards,
bauer
Back to top
View user's profile Send private message
anbesivam
Beginner


Joined: 09 Aug 2006
Posts: 66
Topics: 14

PostPosted: Thu Nov 16, 2006 12:15 pm    Post subject: Reply with quote

Hi Bauer,

Thanks much for understanding my requirement and for your solution.

As you said, My requirement is more than two strings. I also tried all the string functions available in PL1. But nothing helps me on this.
So I will go for following code.

Code:
I = INDEX(X,' ');                         
DO FOREVER;                               
  IF I = 0 ! SUBSTR(X,I) = ' ' THEN LEAVE;
  SUBSTR(X,I) = SUBSTR(X,I + 1);         
  I = INDEX(X,' ');                       
END;                                     
PUT SKIP LIST('X      :',X); 


Hi shaker123,

Hope I am not explained you clearly about my requirement. Really sorry about that.
Any how, Thanks for your reply.
Back to top
View user's profile Send private message
mayuri
Beginner


Joined: 26 Aug 2006
Posts: 17
Topics: 4

PostPosted: Fri Nov 17, 2006 4:17 am    Post subject: Reply with quote

hi Bauer,
you can try this.

Compute the length of the input string into WS-LENGTH

PERFORM VARYING WS-I-CNT FROM 1 BY 1 UNTIL WS-CNT> WS-LENGTH
IF WS-INPUT(WS-I-CNT:1) NOT = SPACE
MOVE WS-INPUT(WS-I-CNT:1) TO WS-OUTPUT(WS-O-CNT:1)
ADD 1 TO WS-O-CNT
END-IF
END-PERFORM
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Fri Nov 17, 2006 5:52 am    Post subject: Reply with quote

Mayuri,
The requirement is to be met in PL/I not in COBOL.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
mayuri
Beginner


Joined: 26 Aug 2006
Posts: 17
Topics: 4

PostPosted: Fri Nov 17, 2006 9:37 am    Post subject: Reply with quote

oh..im so sorry..i havent noticed that..
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group