Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
ISPF search - capturing result

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> TSO/ISPF
View previous topic :: :: View next topic  
Author Message
jzhardy

New User


Joined: 31 Oct 2006
Posts: 47
Location: brisbane

PostPosted: Sat Dec 07, 2019 5:20 am    Post subject: ISPF search - capturing result
Reply with quote

does anyone know if the result of an ISPF edit search is accessible in an ISPF variable ?

eg, from a REXX macro, i might have something like:

"F r'ab.+z'" which would match, for example, "abcdz"

is the result mapped to any .Z variable ?
Back to top
View user's profile Send private message

Willy Jensen

Active User


Joined: 01 Sep 2015
Posts: 331
Location: Denmark

PostPosted: Sat Dec 07, 2019 4:49 pm    Post subject:
Reply with quote

The ISPF EDIT macro FIND service will set rc=0 and the special variable .zcsr to the line number if a match is found.

Sample:
"find ' XXMACS ' first nx"
if rc=0 then "change ' ' '*' .zcsr .zcsr first"

See the 'Edit and Edit Macros' manual for details.
Back to top
View user's profile Send private message
Pedro

Senior Member


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

PostPosted: Tue Dec 10, 2019 11:18 pm    Post subject: Reply to: ISPF search - capturing result
Reply with quote

After the FIND is successful, you can use the CURSOR macro statement to get the line number and column value of where the cursor is. Then use the LINE macro statement to get the entire line. Use rexx PARSE statement to break up the line based on the column offset.
Back to top
View user's profile Send private message
Joerg.Findeisen

New User


Joined: 15 Aug 2015
Posts: 77
Location: Germany

PostPosted: Wed Dec 11, 2019 2:29 am    Post subject:
Reply with quote

@Pedro: You might not get the RegEx search string in full detail when using parse afterwards.
Back to top
View user's profile Send private message
prino

Senior Member


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

PostPosted: Wed Dec 11, 2019 2:46 am    Post subject:
Reply with quote

Use the "macro_msg" edit macro command, and parse the resulting variables, ZEDILMSG, ZEDISMSG, and ZEDMSGNO.
Back to top
View user's profile Send private message
Pedro

Senior Member


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

PostPosted: Wed Dec 11, 2019 11:47 am    Post subject: Reply to: ISPF search - capturing result
Reply with quote

Quote:
You might not get the RegEx search string in full detail


I was guessing it would be a blank delimited string.
Back to top
View user's profile Send private message
Willy Jensen

Active User


Joined: 01 Sep 2015
Posts: 331
Location: Denmark

PostPosted: Wed Dec 11, 2019 12:48 pm    Post subject:
Reply with quote

Ok, slightly better sample than my first one:
"find 'text' first"
if rc=0 then "(r) = line .zcsr"
Back to top
View user's profile Send private message
Joerg.Findeisen

New User


Joined: 15 Aug 2015
Posts: 77
Location: Germany

PostPosted: Wed Dec 11, 2019 2:50 pm    Post subject:
Reply with quote

This snippet works for me.

Code:
"MACRO_MSG = ON"                   
"F r'ab.+z'"                       
parse var ZEDISMSG . "'"string"'" .
say string
Back to top
View user's profile Send private message
jzhardy

New User


Joined: 31 Oct 2006
Posts: 47
Location: brisbane

PostPosted: Tue Dec 17, 2019 8:39 am    Post subject:
Reply with quote

thanks ! works brilliantly

slightly related, is there any way to get capture elements from a matching Regex ?

so, if an input line contained :

xyz : 123

any my match was r'xyz : *([^ ]+) *$'

then it would capture 123
Back to top
View user's profile Send private message
Joerg.Findeisen

New User


Joined: 15 Aug 2015
Posts: 77
Location: Germany

PostPosted: Tue Dec 17, 2019 8:45 am    Post subject:
Reply with quote

Have you tried the code snippet? Guess not.. icon_rolleyes.gif
Back to top
View user's profile Send private message
Joerg.Findeisen

New User


Joined: 15 Aug 2015
Posts: 77
Location: Germany

PostPosted: Tue Dec 17, 2019 8:56 am    Post subject:
Reply with quote

For your RegEx I'd use:

Code:
^xyz[ ]+:[ ]+([0-9])+.*$
Back to top
View user's profile Send private message
jzhardy

New User


Joined: 31 Oct 2006
Posts: 47
Location: brisbane

PostPosted: Fri Jan 03, 2020 8:04 am    Post subject:
Reply with quote

sorry all, some clarification required on my part

my follow up was more about capture elements specifically. A regex expression can have one or more capture elements, identified by bracket pairs.

so, r'x(..)y(..)' would capture :

xyzyab

returning yz into capture element 1 and 'ab' into capture element 2. This is supported by a full implementation of REgex, but suspect it is not possible in ISPF regex.
Back to top
View user's profile Send private message
jzhardy

New User


Joined: 31 Oct 2006
Posts: 47
Location: brisbane

PostPosted: Fri Jan 03, 2020 8:06 am    Post subject:
Reply with quote

.. meaning I want to be able to capture an element into a variable ...
Back to top
View user's profile Send private message
Joerg.Findeisen

New User


Joined: 15 Aug 2015
Posts: 77
Location: Germany

PostPosted: Sat Jan 04, 2020 2:18 pm    Post subject: Reply to: ISPF search - capturing result
Reply with quote

AFAIK it is not (yet) possible with ISPF to have the captured groups as variables.
Back to top
View user's profile Send private message
Pedro

Senior Member


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

PostPosted: Wed Jan 08, 2020 3:41 am    Post subject: Reply to: ISPF search - capturing result
Reply with quote

Quote:
it is not (yet) possible with ISPF to have the captured groups as variables.


You should submit a Request For Enhancment at developerworks. https://www.ibm.com/developerworks/rfe/ You will need to get an userid
Back to top
View user's profile Send private message
Joerg.Findeisen

New User


Joined: 15 Aug 2015
Posts: 77
Location: Germany

PostPosted: Thu Jan 09, 2020 1:40 am    Post subject:
Reply with quote

@Pedro: You only get one or two votes for that and it's being considered niche. Of course ISPF variables ZRE0..9 for up to 10 capture groups are available and it could work like that. The second string in a CHANGE could have r'\0 .. \9' for those variables if the first is also a RegEx but the total unresolved(?) expression length for both must not exceed 256 characters afaik presently.
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 -> TSO/ISPF All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to free (unalloc) data sets and d... Ricardo Viegas TSO/ISPF 4 Wed Jan 15, 2020 5:19 am
No new posts ISPF Edit Macro for modifying JCL Cameron Conacher TSO/ISPF 21 Wed Dec 11, 2019 7:01 pm
No new posts Posting to the ISPF XML API (ISPZXML)... Daboogie TSO/ISPF 1 Tue Oct 15, 2019 10:31 pm
No new posts Adding FIND to ISPF Panel display of ... Harold Barnes TSO/ISPF 3 Mon Oct 07, 2019 5:46 pm
No new posts How to force ISPF to allocate ISPF te... Michele Giannuli TSO/ISPF 9 Thu Sep 12, 2019 2:03 pm

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