Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Replace a String without using PARSE Command

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
vasan_4u

New User


Joined: 28 Jun 2005
Posts: 35
Location: chennai

PostPosted: Thu Jan 10, 2008 12:28 am    Post subject: Replace a String without using PARSE Command
Reply with quote

I have a string like this

STR='&HLQ..&SYS..&JOBNAME..LSCBSA05.SELRPT'

Now i need to replace the &HLQ/&SYS/&JOBNAME to someother value is that possible ?

I cant use PARSE command for the same.
Back to top
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Jan 10, 2008 12:58 am    Post subject:
Reply with quote

What have you tried and what were the results that have prompted you to ask on the forum ?
Back to top
View user's profile Send private message
vasan_4u

New User


Joined: 28 Jun 2005
Posts: 35
Location: chennai

PostPosted: Thu Jan 10, 2008 2:17 am    Post subject:
Reply with quote

I dint try any thing as i dont know how to do a replace.

But i should not be doing it with the PARSE comand.

Can you help me in this.
Back to top
View user's profile Send private message
Douglas Wilder

Active User


Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

PostPosted: Thu Jan 10, 2008 4:51 am    Post subject:
Reply with quote

Yes, it is possible.

1) Which language do you want to do this in, Clist or REXX?
2) Is the string into which you want to replace the variables a constant? Can this be hardcoded into the program?
3) Are the names of the variables to be replaced constant? Can these be hard coded in the program?
4) Could the variables occur more than 1 time in the string?
5) Where are you getting this string?
6) Where are you getting the contents of the variables to put into the string?
7) Have you already coded the program to get the needed strings?

If you are doing this in REXX have you looked at the POS and SUBSTR built-in functions?

If you are doing this in Clist have you looked at symbol substitution?

We try to be helpful but there is a lot about what you are doing that we do not know.
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4650
Location: Raleigh, NC, USA

PostPosted: Thu Jan 10, 2008 5:07 am    Post subject: Reply to: Help in replace ...
Reply with quote

Almost seems like a good candidate for an easy EDIT routine.
Back to top
View user's profile Send private message
vasan_4u

New User


Joined: 28 Jun 2005
Posts: 35
Location: chennai

PostPosted: Tue Jan 15, 2008 2:30 am    Post subject:
Reply with quote

->I am doing it in REXX.
->Those value cannot be hardcoded and its not constant.

For example the value of &HLQ will be LS. which is stored in a aray.

I have coded the program and I have this string alone in a variable.
Back to top
View user's profile Send private message
Douglas Wilder

Active User


Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

PostPosted: Tue Jan 15, 2008 5:10 am    Post subject:
Reply with quote

It would be helpful to see the code you have already developed.
How do you know which element in the array is substituted for each variable?
It appears that you may need to loop using the POS function to find the next "&" then use the POS function to find the next "." use the SUBSTR to find the name of the variable, then use the SUBSTR to put the value in place of the variable name.

It might be easier to do as Kevin suggested, write the string to a dataset, edit it, and do change all commands to replace the variables.
Back to top
View user's profile Send private message
Douglas Wilder

Active User


Joined: 28 Nov 2006
Posts: 305
Location: Deerfield IL

PostPosted: Tue Jan 15, 2008 9:39 pm    Post subject:
Reply with quote

I though I had something like this around somewhere. I found it and modified it to fit your case. I do not know how you will incorporate this into your existing code, but here it is.
Code:
/* REXX */                                                     
TRACE ALL                                                               
VAR = 'HLQ'                                                             
HLQ     = 'ABC'                                                         
SYS     = 'DEFGH'                                                       
JOBNAME = 'IJKLMN'                                                     
/*  STRNG = HLQ||'.'||SYS||'.'||JOBNAME||'.LSCBSA05.SELRPT'   */       
/*  SAY STRNG                                                 */       
STRNG = '&HLQ..&SYS..&JOBNAME..LSCBSA05.SELRPT'                   
SAY STRNG                                                               
STRT = POS('&',STRNG)                                                   
DO WHILE STRT > 0                                                       
    ENND = POS('.',STRNG,STRT)                                           
    VAR = SUBSTR(STRNG,STRT+1,ENND-STRT-1)                               
    STRNG = LEFT(STRNG,STRT-1)||VALUE(VAR)||SUBSTR(STRNG,ENND+1)         
    SAY STRNG                                                             
    STRT = POS('&',STRNG)                                                 
END                                                                     
SAY ' '                                                                 
SAY STRNG                                                               
SAY ' '                                                                 
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 -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts line 52: Name or string > 250 char... Ashishpanpaliya CLIST & REXX 5 Sat Oct 14, 2017 2:29 am
No new posts MQ command in option 6 of ISPF! Vignesh Sid All Other Mainframe Topics 3 Tue Sep 26, 2017 6:01 pm
No new posts Search for a string in many PDS KARTHIGADEVI CLIST & REXX 5 Fri Sep 08, 2017 2:32 pm
No new posts How to change a string containing the... chong.zhou TSO/ISPF 6 Tue Aug 29, 2017 4:54 pm
No new posts Failure after DIR command Hank Watson All Other Mainframe Topics 2 Tue Aug 29, 2017 3:14 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us