Seamless ISPF edit line macros - Sample macro

This is a sample edit macro for the LMAC and UMAC commands. This edit macro implements four commands: 

CECenter all text on each selected line.
RV Reverse all text on each selected line.
LEFMove all text to the far left.
RIT Move all text to the far right.

/* Rexx implement CE, RV, LEF, and RIT line commands                */
Address isredit                              /*  Start of macro     */
"MACRO (PARM) NOPROCESS"                     /*  Get line command   */
Address ispexec "CONTROL ERRORS RETURN"      /*  Return ISPF errors */
If wordpos(parm,"CE RV LEF RIT") = 0 Then    /*  If not a command   */
    Do                                       /*    We expect        */
      zinfo=parm                             /*  Set up for message */
      Address ispexec "SETMSG MSG(ISRE041)"  /*    Invalid command  */
      Exit  8                /* Let ISPF handle the error           */
    End                      /*                                     */
"PROCESS RANGE" parm         /* Get range for command               */
If rc>0  Then                /* if something went wrong             */
  Do                         /*                                     */
    Address ispexec  "SETMSG MSG(ISRZ002)"   /* Set ISPF'S message  */
    Exit  8                  /* Let ISPF handle the error           */
  End                        /*                                     */
"(START) = LINENUM .ZFRANGE" /* Get 1st line number in the range    */
"(STOP)  = LINENUM .ZLRANGE" /* get last line number in the range   */
"(DW)  = DATA_WIDTH"         /* get the width of the editable data  */
Do a = start to stop         /* loop through the range of lines     */
  "(LINE) = LINE "a          /* get old line value                  */
  SELECT                     /* process the command for this line   */
    When(parm = "CE")  Then line=center(strip(line),dw) /* Center   */
    When(parm = "RV")  Then line=reverse(line)          /* Reverse  */
    When(parm = "LEF") Then line=strip(line,"L")    /* Left justify */
    When(parm = "RIT") Then line=right(strip(line,"T"),dw) /* Right
                                                             Justify*/
    Otherwise  Nop           /* Otherwise no op (Shouldn't get here)*/
  End                        /*                                     */
  "LINE "a" = (LINE)"        /* Set new line value                  */
End                          /* end of loop through lines           */
Exit 0                       /* return to ISPF                      */

Return to Seamless Edit Line Macros