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

Find the last occurance of a string in a member.


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
bhagyac

New User


Joined: 17 Apr 2008
Posts: 44
Location: bangalore

PostPosted: Fri Dec 10, 2010 1:20 am
Reply with quote

Hi all,

Is there any command in Rexx, which works as the TSO command, "F last 'search string' "

I want to locate the last occurance of a string in a PDS member and write the entire record in a PS(output) file.

Is there any way to find this, without reading the entire PDS member.??

Thank you.
Back to top
View user's profile Send private message
superk

Global Moderator


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

PostPosted: Fri Dec 10, 2010 2:11 am
Reply with quote

No there is not.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Fri Dec 10, 2010 2:29 am
Reply with quote

Note that edit macros need not be written in Rexx, although they can be.

I recommend that you write such a macro that moves the cursor to the end of the member and then executes a FIND PREV.
Back to top
View user's profile Send private message
John L. McConnell

New User


Joined: 10 Dec 2010
Posts: 11
Location: Orlando, FL

PostPosted: Fri Dec 10, 2010 5:06 am
Reply with quote

The short answer has already been given. But the good news is that there is a fairly fast way, even if it does involve the unavoidable reading of the entire member.
The edit macro suggestion is probably the best way. It would need to be implemented in the context of an algorithm that uses LMMLIST or LISTD pdsname M to produce a member list. You would loop through the member list and ALLOC each member. Then you would invoke EDIT on each member and capture the record found with a FIND LAST.
If that seems daunting, once you have allocated the member, you can do an EXECIO * DISKR on it into a stem variable, such as mem. Fou can actually loop through the records backwards with DO I = mem.0 to 1 by -1. Then in the loop: x = LASTPOS("string",mem.I)
IF x \= 0 then [capture the record and leave the loop]. This is the equivalent of doing a max down and FIND PREV in EDIT. I hope that helps.
Back to top
View user's profile Send private message
bhagyac

New User


Joined: 17 Apr 2008
Posts: 44
Location: bangalore

PostPosted: Fri Dec 10, 2010 3:37 pm
Reply with quote

Thanks a lot to everybody..
i followed John's suggestion. It worked.. icon_biggrin.gif

Thanks to you all!!!
Back to top
View user's profile Send private message
r2k1984

New User


Joined: 21 Jun 2005
Posts: 69
Location: chennai

PostPosted: Mon Dec 20, 2010 3:02 pm
Reply with quote

***************************** Top of Data ****************
/* REXX */
SAY " STRING TO BE SEARCHED" WRITE
ADDRESS ISREDIT
"MACRO "
PULL A
"F .ZL"
"F PREV " A
J1 = "//"USERID()"$ JOB MSGCLASS=X,MSGLEVEL=(1,1),CLASS=B,
J2 = "// REGION=5M,NOTIFY=&SYSUID"
'ISREDIT LINE_AFTER 0 = (J1)'
'ISREDIT LINE_AFTER 1 = (J2)'
**************************** Bottom of Data **************


Below macro to be placed in your ispf macro and you can execute the code and it will work
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Mon Dec 20, 2010 3:19 pm
Reply with quote

Surely
Code:
"ISREDIT F '"string"' LAST"
would suffice
Back to top
View user's profile Send private message
Pedro

Global Moderator


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

PostPosted: Mon Dec 20, 2010 8:20 pm
Reply with quote

Code:
"F .ZL"
"F PREV " A

I think you will not find the text on hthe very last line.
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Mon Dec 20, 2010 11:59 pm
Reply with quote

Code:
"l .zl"
icon_cool.gif
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 Replace each space in cobol string wi... COBOL Programming 2
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 To find whether record count are true... DFSORT/ICETOOL 6
No new posts Find the size of a PS file before rea... COBOL Programming 13
Search our Forums:

Back to Top