Tutorial ----------------- Help for Edit Line
Macros ---------------- Tutorial
Command ===>
This command, , adds hooks into ISPF to allow you to create and
run edit line command macros. With edit line macros, you can define and
run new line commands without having to type anything on the edit command
line.
The line commands are all handled by a single edit macro. You can specify
the name of that macro in the first field of the panel shown by the
command. (The macro you specify can, of course, call other edit
macros to handle the specific details of each line command).
The macro you create will receive one parameter: the name of the line
command that was entered in the editor line command field. Your macro will
receive only the non-block format of the command. For example, if the user
enters QBB, the macro will receive QB because QBB is a block format of the
QB command.
If you only want to pass specific line commands to your macro, select
Process only the line commands listed below and enter the line
commands
you want to process in the table. To let the macro handle all line
commands that the editor doesn't recognize, unselect Process only the line
commands... Passing specific line commands will give better
performance
and makes the macro easier to write.
You can not use this program to override built-in line commands.
You must enter the command once during the ISPF
session to enable
line macros. This can be done automatically by using ! as an
initial macro or by invoking the command
ISREDIT !
within an initial macro. When is called directly from an edit
macro it does not show the pop-up panel.
Once the command has been entered once, it is not necessary to
enter it again during the same ISPF session unless you want to change the
names of the line commands your macro should handle.
Note: For users of recent ISPF versions (ISPF 4.5 and higher): You can set
up an initial macro for all edit sessions by assigning the a macro
name to the variable ZUSERMAC in the PROFILE variable pool. Your
panel has an additional selection field. If you select
Automatically enable line macros and ZUSERMAC is empty,
will automatically set ZUSERMAC to '!' and line macros will
automatically be enabled when you start your first edit session
within an ISPF session.
If you remove from your system and you have selected
'Automatically enable line macros', then you must erase ZUSERMAC
from the profile pool.
All settings are remembered from session to session.
You can discard changes on the Edit Line Macros panel by typing CAN or
CANCEL in the macro name field, or by pressing a CANCEL
program function
key.
An example macro that implements 4 line commands is shown below. The
commands it implements are:
CE Center text on a line
RV Reverse text on a line
LEF Move text all the way left.
RIT Move text all the way 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 */
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 */
------------------------------------------------------------------------
(c) Copyright IBM Corporation, 1999. All rights Reserved.
Author: Doug Nadel
E-mail: nadel@us.ibm.com
------------------------------------------------------------------------
IBM PROVIDES THIS PROGRAM ON AN "AS IS" BASIS WITHOUT WARRANTY OF
ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|