I am looking for help with my REXX script. Which should open an existing Member and search for a specific string.
Here is my script:
/* REXX */
"ALLOC FILE(input) DA('.....(MEMBER)') SHR REUSE"
"EXECIO * DISKR "input" (STEM input. FINIS"
"FREE FILE(input)"
/* Parmlib werden ausgelesen */
do i =1 to input.0
if POS('met,', input.i) > 0 Then
/* Code if string is found */
say Zeile gefunden
else
/* Code if string is not found */
say Zeile nicht gefunden
end
Under ISPF, edit macros seem like a good fit. You can set up an ISPF stack if you're not running one already, works in batch too.
If I'm reading your requirement correctly, maybe something like this might work:
/* REXX-ISPF V/E macro */
Address ISREDIT
"MACRO (needle,dest)"
"CURSOR = 1 0"
lastHit = 0
i = 0
"SEEK "needle
Do While RC=0
"(l#) = CURSOR"
/* Conditional for multiple hits on same line */
If l# > lastHit Then Do /* do */
"(this) = LINE "l#
i=i+1; out.i = this
lastHit = l#
End
"SEEK "needle
End
out.0=i
Address TSO
"ALLOCATE F(OUT) DA("dest"') OLD"
"EXECIO "out.0" DISKW OUT (FINIS STEM out."
Exit 0
You can do this with much fewer lines with more ISPF services in a Macro (X ALL
-> F ALL needle
-> DEL ALL X
-> CREATE dest
). Or through intermittent use of ISPF E clipboard. That has some risks, so not going into that.
Good thing about ISPF E/V Macros is that thy use almost the same command you'd normally use in ISPF E/V. Find is quick. It needs to fit the whole dataset in the Region which might be an issue sometimes.