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
 
Help needed to search and insert a string using REXX

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

New User


Joined: 13 Dec 2007
Posts: 11
Location: USA, California

PostPosted: Tue Jul 08, 2008 7:10 pm    Post subject: Help needed to search and insert a string using REXX
Reply with quote

I need REXX code which does the following:

1. Search a string in all the members
2. If the string is found in any of the member then need to insert a string before the searched string.
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

PostPosted: Tue Jul 08, 2008 7:21 pm    Post subject:
Reply with quote

help yourself.

use the search. I know that there are several examples of search all members.

the insert:

after a find hit:

(workline) = linenum .zcsr

insert <yourstuff> before workline
Back to top
View user's profile Send private message
janaonline

New User


Joined: 13 Dec 2007
Posts: 11
Location: USA, California

PostPosted: Tue Jul 08, 2008 7:25 pm    Post subject:
Reply with quote

Thanks for your immediate reply.

IF VAR3 = 'BEFORE' THEN
DO
I = 1
DO K = 1 TO CONTENTS.0
IF POS( VAR1 , CONTENTS.K) > 0 THEN DO
FOUND = 'Y'
OUTPUT.I = VAR2
I = I + 1
END
OUTPUT.I = CONTENTS.K
I = I + 1
END
END

the above code will insert the string as a separate line, but i need it to insert just before the searched string. Could you please help in this??

Thanks!!!
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

PostPosted: Tue Jul 08, 2008 7:54 pm    Post subject:
Reply with quote

you can do this two ways.

1. use execio to read and write the records for the member. this way you would use stems (as your example). I have no suggestion for this, I would not do it this way.

2. use edit macro commands and have your rexx invoke each member via EDIT, then do your FIND, determine line no of hit, insert before lineno. restart you search at lineno + 1 (you insert a line before line 10, line 10 becomes line 11. if you don't start at line 12, you will be in a loop, finding things on the old line 10 -now 11- and inserting again.)
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: Tue Jul 08, 2008 8:24 pm    Post subject: Reply to: Help needed to search and insert a string using RE
Reply with quote

If you want to stick with using EXECIO instead of an edit macro (which DOES look to be the better option here), you might go with this:

var1 is the search string
var2 is the insertion string

Code:

  "EXECIO * DISKR ddname (STEM contents. FINIS"     
  Do i = 1 To contents.0                       
    If Pos(var1,contents.i) <> 0 Then         
      Do                                       
        Queue var2                             
        Queue contents.i                       
      End                                     
    Else Queue contents.i                     
  End                                         
  "EXECIO "Queued()" DISKW ddname (FINIS"
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10375
Location: italy

PostPosted: Tue Jul 08, 2008 8:46 pm    Post subject: Reply to: Help needed to search and insert a string using RE
Reply with quote

here is a thread with a bit of string manipulation...
http://ibmmainframes.com/viewtopic.php?t=31958&highlight=substr
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

PostPosted: Tue Jul 08, 2008 8:47 pm    Post subject:
Reply with quote

Kevin,

I have failed to say this before, but, you give good advice and your code is clean.
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: Tue Jul 08, 2008 8:55 pm    Post subject: Reply to: Help needed to search and insert a string using RE
Reply with quote

Thanks for the kind words. Maybe I should let my boss read this? icon_wink.gif
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10375
Location: italy

PostPosted: Tue Jul 08, 2008 8:57 pm    Post subject: Reply to: Help needed to search and insert a string using RE
Reply with quote

Quote:
Maybe I should let my boss read this?


Nahhh.....
he might complain that You spend too much time surfing the net icon_wink.gif
Back to top
View user's profile Send private message
janaonline

New User


Joined: 13 Dec 2007
Posts: 11
Location: USA, California

PostPosted: Tue Jul 15, 2008 6:52 pm    Post subject:
Reply with quote

Thanks a lot for all your suggestion. That was really helpful..
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 TBSARG - Deleting the search criteria... ISPFHerc TSO/ISPF 6 Thu Dec 14, 2017 8:18 am
No new posts Looping REXX - unable to interrupt RAVISANKAR07 CLIST & REXX 3 Wed Dec 06, 2017 1:08 pm
No new posts The same REXX program doesnt work for... jackzhang75 CLIST & REXX 5 Wed Dec 06, 2017 2:51 am
No new posts Rexx - File tailoring samzee71 CLIST & REXX 10 Thu Nov 30, 2017 10:47 pm
This topic is locked: you cannot edit posts or make replies. Rexx to Grab ISMF Information. upendrasri All Other Mainframe Topics 16 Sun Nov 26, 2017 12:35 am

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