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
 
TRANSLATE command in REXX

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

New User


Joined: 10 May 2006
Posts: 13

PostPosted: Thu Nov 13, 2008 5:52 pm    Post subject: TRANSLATE command in REXX
Reply with quote

Can any one help me out.

My requirement is, I have to replace the string '@@@' to something in all PDS Members. For this requirement I have written a REXX program. Please find the below piece of code that is not working properly.

Code:
DO J = 1 TO PRG1.0                         
  IF POS('$$$',PRG1.J) > 0  THEN           
     DO                                     
     SAY PRG1.J                             
     SAY SUBSTR(ARR1.I,1,3)                 
     PRG1.J = TRANSLATE(PRG1.J,SUBSTR(ARR1.I,1,3),'@@@')
     SAY PRG1.J                             
     END                                   
END



When I display SUBSTR(ARR1.I,1,3), it is giving correct values.
The problem is with the TRANSLATE command.
TRANSLATE command is replacing '@@@' with the wrong value.

For example : If I give like replace '@@@' with 'ABC'
output is giving like 'AAA' instead of 'ABC'.
(ie; it is replacing whole string with first character of desired string).

I want output as 'ABC' after translate command.

Please let me know why TRANSLATE is not working in this situation? or is there any other command I can use for this requirement?

Regards,
Srinivas.
Back to top
View user's profile Send private message

PeD

Active User


Joined: 26 Nov 2005
Posts: 456
Location: Belgium

PostPosted: Thu Nov 13, 2008 6:11 pm    Post subject:
Reply with quote

Process as you need
and when accurate ( meaning when @@@ is on the line )
override that value using overlay

PRG1.J = Overlay('ABC',PRG1.J,Index(PRG1.J,'@@@'),3)

Be sure Index(PRG1.J) is > 0.


( not tested )


Cheers
Pierre
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10326
Location: italy

PostPosted: Thu Nov 13, 2008 6:14 pm    Post subject: Reply to: TRANSLATE command in REXX
Reply with quote

translate works at byte(char) level,,,
itable = "@@@"
otable = "abc"

rexx logic is to scan the input table and substitute in the output string
the character of the output table which is in the same relative position...


so the first occurence of @ will be used to index the output table
Back to top
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2086
Location: Silicon Valley

PostPosted: Thu Nov 13, 2008 10:38 pm    Post subject: Reply to: TRANSLATE command in REXX
Reply with quote

Your program needs to detect if there are multiple instances of the search string. In your sample program, it only checks for 1 and then goes to the next line.
Back to top
View user's profile Send private message
srinivasbathimmi

New User


Joined: 10 May 2006
Posts: 13

PostPosted: Fri Nov 14, 2008 10:58 am    Post subject: Reply to: TRANSLATE command in REXX
Reply with quote

The below one is working fine.

PRG1.J = Overlay('ABC',PRG1.J,Index(PRG1.J,'@@@'),3)

The above Overlay command is replacing '@@@' with 'ABC' for the first occurance only. Could you please let me know how to replace all occurances of '@@@' to 'ABC'.

Regards,
Srinivas.
Back to top
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 456
Location: Belgium

PostPosted: Fri Nov 14, 2008 12:25 pm    Post subject:
Reply with quote

something like

For every line PRG1 ( sequentially read or in a loop 'J' )

Do While Index(PRG1.J,'@@@') > 0
overlay statement
End


No?
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10326
Location: italy

PostPosted: Fri Nov 14, 2008 12:49 pm    Post subject: Reply to: TRANSLATE command in REXX
Reply with quote

why not use an edit macro???

look at
http://ibmmainframes.com/viewtopic.php?t=25947&highlight=
for a macro that applies a macro to all the members of a pds

and the inner macro would look like

Code:

/*REXX - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* $CHANGE                                                           */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
Trace "O"

Parse Source _system _called _commnd .

If Sysvar(SYSISPF) /= "ACTIVE" Then Do
   Say left(_commnd,8)"- Ispf is not active. Command not executed"
   Exit 4
End

call $init_

call $ispex "CONTROL ERRORS RETURN"

if $isred("MACRO (ZPARMS) NOPROCESS ") = 0 then do
   _parms = strip(translate(zparms))
end
else do
   zerrsm = "Invocation ERROR"
   zerrlm = left(_commnd,8)"- Must be invoked as an edit macro"
   call   $ispex "SETMSG MSG(ISRZ002) "
   Exit 1
end

call $isred "CHANGE '@@@' 'zzz' ALL"

call $isred "END"

Exit

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                                                                   */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
$init_:
   ini_0tr  = trace("O")
   zerralrm = "YES"
   zerrhm   = "ISR2MACR"
   ini_0rc  = 0
   trace value(ini_0tr)
   return ini_0rc

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                                                                   */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
$tsoex:
   tso_0tr = trace("O")
   Address TSO arg(1)
   tso_0rc = rc
   trace value(tso_0tr)
   return tso_0rc

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                                                                   */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
$ispex:
   isp_0tr = trace("O")
   Address ISPEXEC arg(1)
   isp_0rc = rc
   trace value(isp_0tr)
   return isp_0rc

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/*                                                                   */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
$isred:
   isr_0tr = trace("O")
   Address ISREDIT arg(1)
   isr_0rc = rc
   trace value(isr_0tr)
   return isr_0rc


should work for You
Back to top
View user's profile Send private message
srinivasbathimmi

New User


Joined: 10 May 2006
Posts: 13

PostPosted: Fri Nov 14, 2008 1:05 pm    Post subject: Reply to: TRANSLATE command in REXX
Reply with quote

Ped,

As per your suggestion I have modifed the code as below, it is going to infinite loop can you please check it once.

DO J = 1 TO PRG1.0
IF POS('$$$',PRG1.J) > 0 THEN
DO
DO WHILE INDEX(PRG1.J,'$$$') > 0
PRG2.K = OVERLAY(ARR1.I,PRG1.J,INDEX(PRG1.J,'$$$'),3)
END
K = K + 1
END
ELSE
DO
PRG2.K = PRG1.J
K = K + 1
END


Could you please help me out.
Back to top
View user's profile Send private message
PeD

Active User


Joined: 26 Nov 2005
Posts: 456
Location: Belgium

PostPosted: Fri Nov 14, 2008 1:13 pm    Post subject:
Reply with quote

DO J = 1 TO PRG1.0
DO WHILE INDEX(PRG1.J,'$$$') > 0
PRG1.J = OVERLAY(ARR1.I,PRG1.J,INDEX(PRG1.J,'$$$'),3)
END
??? tft to PRG2.n ????
END
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 How to write Rexx program to size and... sreejeshcs CLIST & REXX 14 Thu Oct 12, 2017 7:26 am
This topic is locked: you cannot edit posts or make replies. Rexx to execute spool commands upendrasri CLIST & REXX 5 Wed Oct 04, 2017 6:54 am
This topic is locked: you cannot edit posts or make replies. Rexx to execute spool commands upendrasri CLIST & REXX 47 Fri Sep 29, 2017 1:08 pm
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 ejck thru rexx to multiple jobs insid... Susanta All Other Mainframe Topics 5 Tue Sep 19, 2017 1:39 pm

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