DaveyC Moderator
Joined: 02 Dec 2002 Posts: 151 Topics: 3 Location: Perth, Western Australia
|
Posted: Tue Dec 03, 2002 2:47 am Post subject: REXX ISPF edit macro dialog for managing your labels |
|
|
Here's a simple but useful edit macro I wrote to keep track of labels in source code.
Type LABS on the command line to display current labels, select the row to jump to that label. Type LABS I with the cursor positioned to a line to insert a tokenized label.
Feel free to issue an info message if no labels exist, I am a bit lazy with things like that !
REXX edit macro code:
Code: |
/* REXX ---------------------------------------------------------------
Displays current labels in a pop-up panel
To insert a tokenized label type LABS <parm> where parm is any char
and position the cursor to the line where you want the label inserted
--------------------------------------------------------------------*/
address 'ISREDIT'
"MACRO (ACT)"
"(USRSTAT) = USER_STATE"
upper act
"(ROW,COL) = CURSOR"
"(LINEDTA) = LINE .ZCSR"
if ( act <> '' ) then do
label_token = right( time( 'S' ), 5, 0 )
if row > 0 then do
label = right( translate( label_token, ,
'ABCDEFGHIJ', '0123456789' ), 5 )
'LABEL' row ' = .'label' 0'
exit
end
end
"LOCATE .ZF"
"LOCATE FIRST LABEL"
LabelSelected = 0
if rc = 0 then do
call DisplayLabels
end
if ^ LabelSelected then do
"USER_STATE = (USRSTAT)"
end
exit
DisplayLabels:
/* Create the display table */
address 'ISPEXEC' "TBCREATE LABTAB NAMES(LABEL ROW LINEDATA)" ,
"NOWRITE REPLACE"
do forever
/* Set the display data */
"(ROW,COL) = DISPLAY_LINES"
"(LABEL) = LABEL" row
"(LINEDATA) = LINE" row
/* Add the data to the display table */
address 'ISPEXEC' "TBADD LABTAB"
/* Locate the next label */
"LOCATE LABEL"
if rc > 0 then leave
end
address 'ISPEXEC'
"ADDPOP"
"TBTOP LABTAB"
ztdtop = 0
do forever
/* Display the table */
"TBSKIP LABTAB NUMBER("ztdtop")"
"TBDISPL LABTAB PANEL(LABPAN)"
if rc > 4 then leave
if LineOpt <> '' then do
LabelSelected = 1
address 'ISREDIT' "LOCATE" Label
leave
end
end
"REMPOP"
"TBEND LABTAB"
return
|
Here's the DTL for the panel, which you will need to generate because of the hex characters. Just type TSO ISPDTLC, fill in the fields etc.
Code: |
<!doctype dm system ()>
<varclass name=zcmdCls type='char 40'>
<xlatl format=upper></xlatl>
<varlist>
<vardcl name=zcmd varclass=zcmdCls>
</varlist>
<panel name=labpan
window=yes
wintitle='Select a label'
depth=22
width=70>
<cmdarea>
<topinst>
Select the row to locate the label.
<area>
<lstfld scrollvar=tbscrl>
<lstcol datavar=lineopt usage=in entwidth=1>
<lstcol datavar=label usage=out entwidth=6>Label
<lstcol datavar=row usage=out entwidth=8>Line
<lstcol datavar=LineData usage=out entwidth=46>Data
</lstfld>
</area>
</panel>
|
_________________ Dave Crayford |
|