Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Macro/TSO command to automatically edit any ISPF clipboard

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
Author Message
prino

Active User


Joined: 07 Feb 2009
Posts: 225
Location: Oostende, Belgium

PostPosted: Thu Jul 02, 2009 1:02 pm    Post subject: Macro/TSO command to automatically edit any ISPF clipboard
Reply with quote

The following exec (I've called it EDITCLIP) can be used as both a TSO command and as an edit macro to edit any of the available ISPF clipboards completely under program control.

Code:
/* REXX exec to programatically edit any ISPF clipboard               */
/*** trace ?r ***************************************************** \! *
*               (C) Copyright Robert AH Prins, 2009-2009               *
************************************************************************
*  ------------------------------------------------------------------  *
* ! Date       ! By   ! Remarks                                      ! *
* !------------+------+----------------------------------------------! *
* !            !      !                                              ! *
* !------------+------+----------------------------------------------! *
* ! 2009-07-02 ! RAHP ! Allow selection of Clipboard                 ! *
* !------------+------+----------------------------------------------! *
* ! 2009-06-15 ! RAHP ! Initial version                              ! *
* !------------+------+----------------------------------------------! *
************************************************************************
* EDITCLIP is a REXX exec/edit macro to edit any ISPF clipboard        *
* without manual intervention with a user-specified macro, or manually *
* if no macro is specified.                                            *
*                                                                      *
* The method of automagically processing the ISPF default clipboard    *
* by replacing the ISRECUTL panel was inspired by Doug Nadel's macro   *
* (See <http://sillysot.com/ftp/sdsf_highlighting.txt) to create a     *
* customised ISFPCU41 panel that adds smart highlighting to SDSF.      *
************************************************************************
* This program is free software: you can redistribute it and/or        *
* modify it under the terms of the GNU General Public License as       *
* published by the Free Software Foundation, either version 3 of       *
* the License, or (at your option) any later version.                  *
*                                                                      *
* This program is distributed in the hope that it will be useful,      *
* but WITHOUT ANY WARRANTY; without even the implied warranty of       *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the         *
* GNU General Public License for more details.                         *
*                                                                      *
* You should have received a copy of the GNU General Public License    *
* along with this program. If not, see <http://www.gnu.org/licenses/>  *
***********************************************************************/
parse source source
parse value source with . . moi .
 
"ispexec control errors return"
 
arg parm
"isredit macro (parm)"
 
parse value translate(space(parm, 0)) with clipmac '/' board
 
"ispexec vget (editclip)"
if rc = 0 then
  do
    "ispexec verase (editclip)"
 
    select
      when left(editclip, 1) = x2c(00) then
        do
          editclip = substr(editclip, 2)
 
          select
            when editclip = 'BUILD_ISRECUTL' then
              call build_isrecutl
 
            otherwise
          end
        end
 
      otherwise
    end
  end
else
  do
    /*******************************************************************
    * Build a copy of 'ISRECUTL' with a bit of extra code that allows  *
    * unattended processing of the selected clipboard                  *
    *******************************************************************/
    drop plib
 
    editclip = x2c(0)'BUILD_ISRECUTL'
    "ispexec vput (editclip)"
 
    "ispexec lminit dataid(plib) ddname(ispplib) enq(shr)"
    "ispexec view dataid("plib") member(isrecutl) macro("moi")"
    "ispexec lmfree dataid("plib")"
 
    /*******************************************************************
    * Set up the initial macro                                         *
    *******************************************************************/
    "ispexec vget (zusermac) profile"
    savemac  = zusermac
    zusermac = strip(left(clipmac, 8))
 
    "ispexec vput (board)"
    "ispexec vput (zusermac) profile"
    "ispexec select pgm(isrclipb)"
 
    zusermac = savemac
    "ispexec vput (zusermac) profile"
 
    /*******************************************************************
    * Clean up                                                         *
    *******************************************************************/
    "ispexec qlibdef ispplib id(id)"
    "ispexec libdef ispplib"
    "free f("id")"
  end
exit
 
/***********************************************************************
* BUILD_ISRECUTL:                                                      *
*                                                                      *
* This procedure retrieves the original ISRECUTL panel, provided it is *
* in a dataset allocated to ISPPLIB. It adds some code to the panel to *
* enable editing the clipboard without user intervention. The modified *
* panel is saved into a temporary dataset that is subsequently used in *
* a LIBDEF of ISPPLIB.                                                 *
***********************************************************************/
build_isrecutl:
  "isredit macro"
 
  dynlib = 'pan'random(99999)
  alloc  = "alloc fi("dynlib") rtdsn(sysdsname) "   !!,
                     "lrecl(80) blksize(0) dir(5) " !!,
                     "new delete reuse "            !!,
                     "space(1,1)"
  rc = bpxwdyn(alloc)
 
  if rc = 0 then
    ispdyn = sysdsname
  else
    ispdyn = 'NOT FOUND'
 
  "newstack"
 
  "isredit (ZL) = linenum .zl"
 
  do i = 1 to zl
    "isredit (L) = line" i
 
    if left(l, 5) = ')PROC' then
      do
        /***************************************************************
        * Insert additional code into the 'INIT' section               *
        ***************************************************************/
        queue '/* Additional INIT code */'
        queue 'vget (board)'
        queue ' '
        queue '*rexx(zcutlist,board,autoclip)'
        queue '  ok = 0'
        queue ' '
        queue '  if autoclip \= ''OK'' then'
        queue '    do cb = 5 by 63 to length(zcutlist) until ok'
        queue '      ok = strip(substr(zcutlist, cb, 8)) = board'
        queue '    end'
        queue ' '
        queue '  if \ok then'
        queue '    zcutlist = overlay(''E'', zcutlist, 3)'
        queue '  else'
        queue '    zcutlist = overlay(''E'', zcutlist, cb - 2)'
        queue '*endrexx'
        queue ' '
        queue 'if (&autoclip = &z)'
        queue '  .resp=enter'
        queue 'else'
        queue '  .resp=end'
 
        queue l
 
        /***************************************************************
        * Insert additional code into the 'PROC' section               *
        ***************************************************************/
        queue '/* Additional PROC code */'
        queue '&autoclip = OK'
      end
    else
      queue l
  end
 
  tfil = 'tfil'random(9999)
 
  "alloc f("tfil") da('"ispdyn"(isrecutl)') shr reu"
  "execio" queued() "diskw "tfil" (finis"
  "free f("tfil")"
 
  "delstack"
 
  "isredit can"
 
  "ispexec libdef ispplib library id("dynlib") stack"
return
/***********************************************************************
Structure of zcutlist, for clarity the actual attribute characters 01,
02, 03 and 04 have been replaced by {, }, [ and ]. The three rows below
are all concatenated!
 
{ 01 TYPE(DATAOUT)
} 02 TYPE(DATAOUT) INTENS(LOW)
[ 03 TYPE(DATAIN)  JUST(LEFT) HILITE(USCORE)
] 04 TYPE(DATAIN)  CAPS(ON)   HILITE(USCORE)
....v....1....v....2....v....3....v....4....v....5....v....6...
 ] {DEFAULT }      21[ISPF Default Clipboard                  {
 ] {WHATEVER}      20[A user defined clipboard                {
 ] {ANOTHER }      20[Another user defined clipboard          {
***********************************************************************/


Invocation is either "TSO EDITCLIP {macro}{/clipboard}" or, if in Edit or View, just "EDITCLIP {macro}{/clipboard}"

The invocation parameters are

  • macro: the edit macro to process the contents of the selected clipboard
  • clipboard: the clipboard to process. If the specified clipboard does not exist, EDITCLIP will process the always present DEFAULT clipboard.
To just view a clipboard, "macro" can be omitted, but the slash must be included. Omitting both "macro" and "/clipboard" will display the ISPF Default clipboard.

Be careful with PC-MF transfers, the '\!' on the second line of the source indicate the NOT(\) and OR(!) characaters.

Enjoy,

Robert
Back to top
View user's profile Send private message
References
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1