Your original questions asked for "I want to write a REXX that I can execute 
from the Command Line while editing a dataset [...]". If you're editing a 
dataset you can run Edit macros, which means your macro can easily obtain the 
line at the cursor:

address ISREDIT
   "(CSRROW,CSRCOL) = CURSOR"
   "(CSRLINE) = LINE .ZCSR"

Then you need to do some parsing to grab the data set name at csrcol on the 
csrline.


If, on the other hand, you want a command that can work in ANY ISPF screen, you 
need use the zscreeni and other variables to get a the raw screen data. This 
data is a stream, so if you want to make sure you don't parse across lines, you 
have to do some work.

You can figure out the logical screen width using this code; it is from a 
Usenet posting by Doug Nadel:

logical_screen_width: procedure
          tcb   = ptr(540)             /* TCB (EXEC command)  PSATOLD */
          tcb   = ptr(tcb+132)         /* TCB (ISPTASK)       TCBOTC  */
          fsa   = ptr(tcb+112)         /* first save area     TCBFSA  */
          r1    = ptr(fsa+24)
          tld   = ptr(r1)              /* TLD address                 */
          clswd = ptr(tld+192)         /* best guess at real width    */
          return clswd

ptr:  Return c2d(bitand(storage(d2x(Arg(1)),4),'7FFFFFFF'x))


This code will give you the cursor position in the logical screen; same as 
csrrow & csrcol in the macro example:

get_ISPF_cursor_position: procedure,
          expose csrrow csrcol
          address ISPEXEC "VGET ZSCREENC"
          lscreenw = logical_screen_width()
          csrrow   = (zscreenc % lscreenw) + 1
          csrcol   = zscreenc - (csrrow-1)*lscreenw + 1
          return


This code will give you a line of data at the cursor row:

get_ISPF_line: procedure
          arg row
          address ISPEXEC "VGET ZSCREENI"
          lscreenw = logical_screen_width()
          line  = substr(zscreeni, (row-1)*lscreenw +1, lscreenw)
          return line


And now you can get the line at the cursor, same as in the macro example:

get_cursor_line_in_ISPF:
          call get_ISPF_cursor_position    /* returns csrrow & csrcol */
          csrline  = get_ISPF_line(csrrow)
          return


Once you have the line and the cursor position, you need to do the same parsing 
to isolate and extract the data set name.

Hint: A DSN can contain letters, numbers, and @#$.()+-. Change anything else to 
spaces, then your DSN is the word at the cursor.


-----Original Message-----
From: IBM Mainframe Discussion List <[email protected]> On Behalf Of 
Steve Beaver
Sent: Tuesday, September 16, 2025 12:54 PM
To: [email protected]
Subject: Re: This is a How do I do

Basically what I would like to do is do What Quickref does.  Put that cursor on 
the DSN and have that DSN opened
In a VIEW after putting a DS on the COMMAND line

//VSH1     JOB   MSGLEVEL=(1,1),MSGCLASS=A,NOTIFY=&SYSUID
 //COMPILE  EXEC  PGM=IGYCRCTL,REGION=0M,
 //         PARM='LIST,NOSEQ,MDECK'
 //STEPLIB  DD DISP=SHR,DSN=IGY640.SIGYCOMP
//SYSPRINT DD SYSOUT=*
//SYSIN    DD DISP=SHR,DSN=PHS.PDS.SOURCE(VSH1)
//SYSMDECK DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSLIN   DD DISP=SHR,DSN=PHS.PDS.OBJ(VSH1)
//SYSLIB   DD DISP=SHR,DSN=VSH.BASE840.SAMPLIB


-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf 
Of Willy Jensen
Sent: Monday, September 15, 2025 2:15 AM
To: [email protected]
Subject: Re: This is a How do I do

Maybe this will help..
In your program.do a
  address ispexec "vget (zscreeni zscreenc zscreenw zscreend)"

zscreeni   is an image of the entire screen in text format.
zscreenc  is the cursor position in that image
zscreenw  is the screen width
zscreend  is the screen depth

Using the image and cursor pos, you can pick the information that the cursor 
points to and act accordingly.
This also works in an edit macro.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN



----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to