View previous topic :: View next topic
|
Author |
Message |
MARINA JOSEPH
New User
Joined: 11 Jun 2009 Posts: 61 Location: chennai
|
|
|
|
Hi,
I have an array of strings in FSTRING.J.
Like ACT-POL-APPL-SEG-CNT, ACT-POL-DROPPED-CLM-CNT, ACT-POL-REINST-DATE etc..
Code: |
IF POS_WORD <> 0 THEN
DO
FSTRING.J = WORD(STRING,POS_WORD-1)
IF SUBSTR(FSTRING.J,1,3) = 'ACT'
OVERLAY( "MAS" ,"ACT")
SAY FSTRING.J |
I need to replace the characters ‘ACT’ in every word with ‘MAS'.
Could somebody tell if the above approach is right?
Thanks. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
You really do need to spend some more time on describing your problem, so please explain exactly what you want to do.
Is the source in a dataset, a single member of a PDS, all members in a PDS or what.
Are you saying that each entry in the stem FSTRING has multiple fields with multiple occurences of "ACT" as shown in your post, or is each element shown really a part of the stem, as shown below.
FSTRING.1 = ACT-POL-APPL-SEG-CNT
FSTRING.2 = ACT-POL-DROPPED-CLM-CNT
FSTRING.3 = ACT-POL-REINST-DATE |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
if it works it is right, but it does not mean that You could not do better
here is a better solution
Code: |
f = "abc" ;
t = "xyz"
l = length(t)
s.1 = "abc"
s.2 = "abc1abc"
s.3 = "abc1abc22abc"
s.4 = "abc1abc22abc3333abc"
s.5 = "abc1abc22abc3333abc4444abc"
s.6 = "abc1abc22abc3333abc4444abc55555abc"
s.7 = "abc1abc22abc3333abc4444abc55555abc666666abc"
s.0 = 7
do i = 1 to s.0
w = S.I
p = pos(f,W)
do while p > 0
w = overlay(t,w,p,l)
p = pos(f,w)
end
s.i = w
end
do i = 1 to s.0
say right(i,2) s.i
end |
|
|
Back to top |
|
|
MARINA JOSEPH
New User
Joined: 11 Jun 2009 Posts: 61 Location: chennai
|
|
|
|
The source is in a single member of a PDS.
I am writing a MACRO which will read variables from a copybook and replace the string ACT to MAS. The variables have been read into a stem variable.
The second scenario is right.
FSTRING.1 = ACT-POL-APPL-SEG-CNT
FSTRING.2 = ACT-POL-DROPPED-CLM-CNT
FSTRING.3 = ACT-POL-REINST-DATE |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Wouldn't an ISPF edit macro be a quicker and cleaner way to go ? Which would also cater for differing lengths of in and out ...
Code: |
"ISREDIT C 'ACT-' 'MAS-' ALL"
"ISREDIT END"
|
Enrico, nice solution - almost the same as the one I was going to post until I saw that you had. |
|
Back to top |
|
|
|