View previous topic :: View next topic
|
Author |
Message |
bhagyac
New User
Joined: 17 Apr 2008 Posts: 44 Location: bangalore
|
|
|
|
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 |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
No there is not. |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
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 |
|
|
John L. McConnell
New User
Joined: 10 Dec 2010 Posts: 11 Location: Orlando, FL
|
|
|
|
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 |
|
|
bhagyac
New User
Joined: 17 Apr 2008 Posts: 44 Location: bangalore
|
|
|
|
Thanks a lot to everybody..
i followed John's suggestion. It worked..
Thanks to you all!!! |
|
Back to top |
|
|
r2k1984
New User
Joined: 21 Jun 2005 Posts: 69 Location: chennai
|
|
|
|
***************************** 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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Surely
Code: |
"ISREDIT F '"string"' LAST" |
would suffice |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2546 Location: Silicon Valley
|
|
|
|
Code: |
"F .ZL"
"F PREV " A |
I think you will not find the text on hthe very last line. |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
Back to top |
|
|
|