Page 2 of 3

Re: REXX w/ ISPEXEC VIEW and obtaining data from it

PostPosted: Sat Dec 10, 2022 12:22 pm
by Pedro
I forgot to include the DEFINE keyword:

2. The editor macro is a separate rexx program that you supply. In this rexx program (named MYMACRO in this example), use Address ISREDIT to set an alias for 'F', so that when you issue the FIND, it runs a third rexx program. I am unsure of the syntax, but something like this:
Address ISREDIT "DEFINE F ALIAS myfind01"
Address ISREDIT "DEFINE FIND ALIAS myfind01"

Re: REXX w/ ISPEXEC VIEW and obtaining data from it

PostPosted: Sun Dec 11, 2022 6:22 pm
by prino
Pedro wrote:It is non-trivial because you want to invoke view AND also intercept your find command. My suggestion involves three separate rexx programs:

I don't read that into the OP.

The macro invoked when performing the VIEW can save the line in which the string is found in the shared pool, can find the dataset (and for a PDS, member, version and level) and store those in the shared pool. Hell, it can even retrieve the string-to-be-found from that pool.

I'm not sure why you are complicating matters with by adding a third exec...

Re: REXX w/ ISPEXEC VIEW and obtaining data from it

PostPosted: Mon Dec 12, 2022 6:33 pm
by willy jensen
Interesting, I haven't worked with the DEFINE .. ALIAS before.
It worked, like so:
address ispexec "VIEW DATASET('my.dataset') macro(afind1)"  

AFIND1:
/* alternate FIND - redefine F and FIND commands     rexx  */
 Address Isredit "MACRO PROCESS"                            
 Address ISREDIT "Define F    alias AFIND2"                  
 Address ISREDIT "Define FIND alias AFIND2"

AFIND2:
/* alternate FIND - perform the FIND and proces the line    rexx */
 Address Isredit "MACRO PROCESS (WHAT)"                            
 Address Isredit                                                  
 "(ds)=dataset"                                                    
 "(mb)=member "                                                    
 "SEEK '"what"'"                                                  
 if rc=0 then do                                                  
   "(p) = linenum .zcsr"                                          
   "(l) = line (p)"                                                
   say 'text='strip(l,'t')                                        
 end      

Note the use of SEEK instead of FIND as FIND will send AFIND2 into a recursive spin.
AFIND2 just does a SAY, but you can do whatever you need there like VPUT, add to an ISPF table, write to a dataset....

@Jeff R, what do you need the ZTITLE for? datasetname and membername are in EDIT variables DATASET and MEMBER respectively.

Re: REXX w/ ISPEXEC VIEW and obtaining data from it

PostPosted: Mon Dec 12, 2022 11:49 pm
by Pedro
FIND will send AFIND2 into a recursive spin.

My recommendation was to use the BUILTIN service to avoid the recursiveness.

Re: REXX w/ ISPEXEC VIEW and obtaining data from it

PostPosted: Mon Dec 12, 2022 11:52 pm
by Pedro
what do you need the ZTITLE for? datasetname and membername are in EDIT variables DATASET and MEMBER respectively.


The dataset name and member name were already known names in the original post, as they were used to launch the VIEW.

Re: REXX w/ ISPEXEC VIEW and obtaining data from it

PostPosted: Tue Dec 13, 2022 12:26 am
by willy jensen
@Pedro "recommendation was to use the BUILTIN service" - indeed you did, missed that.Though in this particular case I think I would use SEEK anyway.

Re: REXX w/ ISPEXEC VIEW and obtaining data from it

PostPosted: Wed Dec 21, 2022 11:08 am
by Jeff R
Was able to work around the issue I was having...now a new one.
I'm wanting to change all occurrences of string "(+1)" to '(0)" which is working as expected...next I want to change all occurrences of string "&BR0" (this is NOT a variable) to "(0)" and I can't get the CHANGE command to work.
Example of my CHANGE command for the "(+1)" string is :
"CHANGE "CHANGDSN.I'(+1)'" "CHANGDSN.I'(0)'" ALL"
where CHANGDSN is a string found and I is the "array index"
when I try "CHANGE "CHANGDSN.I'&BR0'" "CHANGDSN.I'(0)'" ALL" it doesn't work...nothing happens/is changed...I am assuming that it thinks the &BR0 is a variable

Re: REXX w/ ISPEXEC VIEW and obtaining data from it

PostPosted: Wed Dec 21, 2022 1:59 pm
by willy jensen
not particular nice looking, but for complicated strings I have found it simpler to change to hexadecimal representation and use that, i.e._

fx=c2x("DSN.I'&BR0'")    
tx=c2x("DSN.I'(0)")      
"CHANGE x'"fx"' x'"tx"'"

Re: REXX w/ ISPEXEC VIEW and obtaining data from it

PostPosted: Wed Dec 21, 2022 2:06 pm
by prino
willy jensen wrote:not particular nice looking, but for complicated strings I have found it simpler to change to hexadecimal representation and use that, i.e._

fx=c2x("DSN.I'&BR0'")    
tx=c2x("DSN.I'(0)")      
"CHANGE x'"fx"' x'"tx"'"

You beat me to that. ;)

Re: REXX w/ ISPEXEC VIEW and obtaining data from it

PostPosted: Wed Dec 21, 2022 2:23 pm
by Jeff R
Thanks !...had to tweak it a bit, but it worked