macroseditzosmvsispf

How to change primary command in Edit


I want to add some shortcuts in ISPF Edit.

For instance, I'd like to type T for "TOP" and B for "BOT". How can I do this? I tried to enter

define t alias top

in the command line, but it didn't work: I have "COMMAND TOP NOT FOUND" if I use the shortcut.

How can I achieve this? And how to have this shortcut available each time I open Edit?


Solution

  • A flexible solution would be to create an initial edit macro that does double duty. On first invocation as the initial edit macro, it defines commands such as T and B as aliases to itself. These commands then cause ISPF to invoke the same macro and perform the appropriate action. For this, use the ISPF variable ZEDTMCMD as the main logic driver; it is set by the editor with the command that invoked the macro.

    Here is a very general REXX solution called MYMACRO:

    /* REXX */                                                               
    address 'ISREDIT'                                                        
    parse source . . s3 .                                                    
    'MACRO'  /* You can specify optional arguments if you want */            
    
    /* Easier to work with upper case and no leading or trailing blanks */   
    address 'ISPEXEC' 'VGET (ZEDTMCMD)'                                      
    invoke_cmd = translate(strip(zedtmcmd))                                  
    
    select                                                                   
      when invoke_cmd == s3 then do /* first time call */                    
        'DEFINE T ALIAS' s3                                                  
        'DEFINE B ALIAS' s3                                                  
      end                                                                    
      when invoke_cmd == 'T' then 'UP MAX'                                   
      when invoke_cmd == 'B' then 'DOWN MAX'                                 
      otherwise nop                                                          
    end                                                                      
    exit 0                                                                   
    

    Next, specify MYMACRO as a initial edit macro. This can be specified in several places, but the easiest is on the main edit panel (option 2).

    ISPF Edit Entry Panel with highlight of initial macro field

    Note that your macro needs to be in the standard lookup (DD SYSEXEC, SYSPROC, or DD SYSUEXEC or SYSUPROC if ALTLIB is active, or ISPCLIB) to be found.

    If you decide to write a program, it is a little bit more complicated. You have to:

    In this scenario, when executed as the initial edit macro, ZEDTMCMD will have the leading exclamation point.

    By creating one macro, you can make it easier to add new commands in the future.

    The ISPF installation SAMPLIB (usually named ISP.SISPSAMP, but it may be different at your installation) has several example macros, all beginning with ISR*. There are REXX scripts, CLISTs, COBOL, and PL/I examples. (No assembler, but creating one is a trivial exercise.)