REXX w/ ISPEXEC VIEW and obtaining data from it



IBM's Command List programming language & Restructured Extended Executor

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

Postby Pedro » Sat Dec 10, 2022 12:22 pm

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"
Pedro Vera
User avatar
Pedro
 
Posts: 672
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 51 times

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

Postby prino » Sun Dec 11, 2022 6:22 pm

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...
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 635
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 28 times

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

Postby willy jensen » Mon Dec 12, 2022 6:33 pm

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.
willy jensen
 
Posts: 419
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 61 times

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

Postby Pedro » Mon Dec 12, 2022 11:49 pm

FIND will send AFIND2 into a recursive spin.

My recommendation was to use the BUILTIN service to avoid the recursiveness.
Pedro Vera
User avatar
Pedro
 
Posts: 672
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 51 times

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

Postby Pedro » Mon Dec 12, 2022 11:52 pm

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.
Pedro Vera
User avatar
Pedro
 
Posts: 672
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 51 times

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

Postby willy jensen » Tue Dec 13, 2022 12:26 am

@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.
willy jensen
 
Posts: 419
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 61 times

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

Postby Jeff R » Wed Dec 21, 2022 11:08 am

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
Jeff R
 
Posts: 27
Joined: Fri Dec 09, 2022 6:59 pm
Has thanked: 4 times
Been thanked: 0 time

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

Postby willy jensen » Wed Dec 21, 2022 1:59 pm

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"'"
willy jensen
 
Posts: 419
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 61 times

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

Postby prino » Wed Dec 21, 2022 2:06 pm

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. ;)
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 635
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 28 times

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

Postby Jeff R » Wed Dec 21, 2022 2:23 pm

Thanks !...had to tweak it a bit, but it worked
Jeff R
 
Posts: 27
Joined: Fri Dec 09, 2022 6:59 pm
Has thanked: 4 times
Been thanked: 0 time

PreviousNext

Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post