/* REXX ***************************************************************/
/*** */
/*** ISPF/PDF edit macro to write lines from a file to the user */
/*** PROFILE pool for later inclusion by the PASTE macro. */
/*** */
/*** To run: */
/*** Enter CUT on the COMMAND line and use the C or M line commands */
/*** (in any form) to select the lines to be cut. */
/*** */
/*** If the M line command is used, the lines will be deleted. */
/*** */
/*** A parameter of R or REPLACE can be specified to replace any */
/*** previously CUT lines (that have not yet been PASTEd) with the */
/*** newly selected lines. Otherwise, the selected lines will be */
/*** added to any previously CUT lines. */
/*** */
/*** An arbitrary limit of 1000 lines is set in the macro but this */
/*** can be changed by providing a new limit on the macro call. */
/*** For example, to process up to 2000 lines enter CUT 2000 on the */
/*** COMMAND line. Be aware that each line gets stored in your */
/*** PROFILE. */
/*** */
/**********************************************************************/
Trace
Address ISPEXEC
'ISREDIT MACRO (PARM1) NOPROCESS'
parm1 = translate(parm1)
If parm1 = '?' Then
Do
Call help
Exit
End
If parm1 ^= ' ' & parm1 ^= 'R' & parm1 ^= 'REPLACE' Then
Do
If datatype(parm1,w) = 1 & parm1 > 0 Then
Do
/* set new limit for maximum number of lines cut to profile */
cutlimit = parm1
'VPUT (CUTLIMIT) PROFILE'
End
Else
Do
zedsmsg = 'Invalid parameter'
msg = 'Use a whole number > 0, ? for help,'
zedlmsg = msg 'R or REPLACE to replace previous lines'
'SETMSG MSG(ISRZ001)'
Exit 12
End
End
/* Process line commands, check if C or M was specified */
'ISREDIT PROCESS RANGE C M'
Select
When rc = 0 Then
Do
'ISREDIT (CMD) = RANGE_CMD' /* Get the command */
'ISREDIT (LINE1) = LINENUM .ZFRANGE' /* Get first line in range*/
'ISREDIT (LINE2) = LINENUM .ZLRANGE' /* Get last line in range */
linestocut = line2 - line1 + 1
End
When rc <= 4 Then /* No C or M entered */
Do
zedsmsg = 'Enter "C"/"M" line cmd'
zedlmsg = 'CUT requires a "C" or "M" line command'
'SETMSG MSG(ISRZ001)'
Exit 12
End
Otherwise /* Line command conflict - Edit will create message*/
Exit 12
End
/* Get the number of lines that have been cut but not pasted, */
/* initialize to zero if first time. */
'VGET (CUTCNTMX) PROFILE'
If rc ^= 0 Then
cutcntmx = 0
/* Get the maximum number of lines to be stored in the profile, */
/* initialize to 1000 if first time. */
'VGET (CUTLIMIT) PROFILE'
If rc ^= 0 Then
Do
cutlimit = 1000
'VPUT (CUTLIMIT) PROFILE'
End
If parm1 = 'R' | parm1 = 'REPLACE' Then
Do
If linestocut < cutcntmx Then
Do
/* delete variables that will not be overwritten */
'VGET (ZENVIR) SHARED'
Do i = 1 to cutcntmx by 1
'VERASE (CL'i') PROFILE'
End
End
cutcntmx = 0
End
cutcntmxsave = cutcntmx
/* Check to see if the limit will be exceeded by storing the lines */
/* into the profile. */
count = cutcntmx + linestocut
If count > cutlimit Then
Do
zedsmsg = '> 'cutlimit 'lines to cut'
zedlmsg = 'Reduce the range or change limit with CUT 'count
'SETMSG MSG(ISRZ001)'
Exit 12
End
/* cut the lines to the profile */
cutcnt = cutcntmx
Do i = line1 to line2
cutcnt = cutcnt + 1
'ISREDIT (CL'cutcnt') = LINE' i
Interpret "CL"cutcnt"= Strip(CL"cutcnt",'T')"
'VPUT (CL'cutcnt') PROFILE'
End
/* Put the number of lines cut into the profile for use by PASTE */
'VPUT (CUTCNT) PROFILE'
/* If the number of lines cut this time is greater than the maximum */
/* cut, then save the new maximum. PASTE will set this variable to */
/* zero if it deletes the variables. */
If cutcnt > cutcntmx Then
Do
cutcntmx = cutcnt
'VPUT (CUTCNTMX) PROFILE'
End
If cmd = 'M' Then
Do
'ISREDIT DELETE 'line1 line2
If cutcntmxsave = 0 Then
Do
zedsmsg = linestocut 'lines cut and deleted'
msg = 'lines were cut and deleted from the current file'
zedlmsg = linestocut msg
End
Else
Do
zedsmsg = linestocut 'lines cut and deleted'
msg ='A total of 'cutcntmx' lines have been cut'
zedlmsg = msg '- last 'linestocut' were deleted'
End
'SETMSG MSG(ISRZ000)'
End
Else
Do
If cutcntmxsave = 0 Then
Do
zedsmsg = linestocut 'lines cut'
zedlmsg = linestocut 'lines were cut from the current file'
End
Else
Do
zedsmsg = linestocut' lines plus 'cutcntmxsave 'lines cut'
zedlmsg ='A total of 'cutcntmx' lines have been cut'
End
'SETMSG MSG(ISRZ000)'
End
Exit
help:
Say ' '
Say ' ISPF/PDF edit macro to write lines from a file to the user '
Say ' PROFILE pool for later inclusion by the PASTE macro. '
Say ' '
Say ' To run: '
Say ' Enter CUT on the COMMAND line and use the C or M line commands'
Say ' (in any form) to select the lines to be cut. '
Say ' '
Say ' If the M line command is used, the lines will be deleted. '
Say ' '
Say ' A parameter of R or REPLACE can be specified to replace any '
Say ' previously CUT lines (that have not yet been PASTEd) with the '
Say ' newly selected lines. Otherwise, the selected lines will be '
Say ' added to any previously CUT lines. '
Say ' '
Say ' An arbitrary limit of 1000 lines is set in the macro but this '
Say ' can be changed by providing a new limit on the macro call. '
Say ' For example, to process up to 2000 lines enter CUT 2000 on the'
Say ' COMMAND line. Be aware that each line gets stored in your '
Say ' PROFILE. '
Say ' '
Return
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN