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

Replace a String without using PARSE Command


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
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
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: 8797
Location: Welsh Wales

PostPosted: Thu Jan 10, 2008 12:58 am
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
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
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

Global Moderator


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

PostPosted: Thu Jan 10, 2008 5:07 am
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
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 Routing command Address SDSF to other... TSO/ISPF 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts DTL - how to define key with stacked ... TSO/ISPF 3
Search our Forums:

Back to Top