Syntax


NDELETE

string [ PREFIX | SUFFIX | WORD | CHAR

[ start-column [ end-column ] ]

[ line-control-range ]

[ color-selection-criteria ]

[ X | NX ]

[ U | NU ]

[ ALL | FIRST | LAST | NEXT | PREV ]

[ TOP ]


Operands


string

For NDELETE, the string option is required; unlike the DELETE command, all NDELETE operations are string-based. Lines not containing string are deleted within the selected line range. If neither ALL, FIRST, LAST, PREV or NEXT is specified, NEXT is assumed. The string may be unquoted, or simply quoted, or may be any of the standard string types C, T, X, P or R.


CHARS | WORD

PREFIX | SUFFIX

These options describe the “string context” in the same way that a FIND or CHANGE command does. 


If omitted for a string-based delete, the string will be searched for in WORD mode if C W or T W appears in the middle of the status line, and in CHARS mode if C or W appears in the middle of the status line. WORD mode or CHARS mode can be set by FIND WORD or FIND CHARS, respectively.


start-column

Left column of a range (with end-column) within which the search-string value must be found. If no end-column operand, then the search-string operand must be found starting in start-col.


end-column

Right column of a range (with start-column) within which the search-string value must be found.


line-control-range

The range of lines which are to be processed by the command. Line control ranges provide a powerful tool to customize the range of lines to be processed. The full syntax and allowable operands which make up a line control range are discussed in "Line Control Range Specification". Refer to that section of the documentation for details.


color-selection-criteria

A request for selection based on the highlight color of the search-string. Color requests provide another powerful tool to control search selection. The full syntax and allowable operands which make up a color-selection-criteria  are discussed in "Color Selection Criteria Specification". Refer to that section of the documentation for details.


ALL

All lines in the line range not having the search string are deleted. Unlike the DELETE command, ALL is not assumed for NDELETE if ALL, FIRST, LAST, NEXT and PREV are omitted.


X | NX

Specifies a subset of the line range to be processed. X requests only excluded lines are to be deleted, NX requests only non-excluded lines are to be deleted. If neither X or NX are specified, all lines in the range will be eligible to be deleted.


U | NU

Specifies a subset of the line range to be processed. U requests only User lines are to be processed, NU requests only non-User lines are to be processed. If neither U or NU are specified, all lines in the range will be processed.


FIRST | NEXT

Starts at the top of the specified range and searches ahead to find the first occurrence in the specified line-control-range and delete that line. NEXT is assumed if ALL, FIRST, LAST, NEXT or PREV are omitted.


LAST | PREV

Starts at the bottom of the specified range and searches backward to find the last occurrence in the specified line-control-range and delete that line.


TOP

Normally, at the completion of the command, the first, or only, line processed is highlighted (if it is on the current screen) or the screen is scrolled to the 2nd screen line (as ISPF does) if the line is not on the current screen. If TOP is coded, then the line is always positioned as the top line of the screen, regardless of its current location.


 

Abbreviations and Aliases

 

NDELETE can also be spelled as NDEL

PREFIX can also be spelled as PRE or PFX

SUFFIX can also be spelled as SUF or SFX

WORDS can also be spelled as WORD

CHARS can also be spelled as CHAR

  

Description


NDELETE removes one or more lines from the edit file where a given string is not found.


Specifying the Lines to NDELETE


Two methods of specifying the data are possible.


    • The first is the classic ISPF method of specifying line numbers as operands to the NDELETE command. You have the full range of options allowed by SPFLite's extended line-control-range operands. 


    • Or, the lines may be marked by C/CC line commands. 


Depending on whether the X or NX operands are specified, the data deleted will be the entire contents of the specified line range if these operands are omitted, or the specified subset (X or NX) if the operands are specified. 


The options ALL, FIRST, LAST, PREV and NEXT are all available. 


Examples of the NDELETE command


To delete all excluded lines not containing ABC:


NDELETE ABC ALL X


To delete all non-excluded lines not containing ABC:


NDELETE ABC ALL NX


To delete a range of lines not containing ABC using line numbers:


NDELETE ABC ALL 20 30


To delete a range of lines not containing ABC using line labels:


NDELETE ABC ALL .HERE .THERE


To delete only excluded lines not containing ABC within a range of lines using line numbers:


NDELETE ABC ALL X 25 35


To delete lines not containing ABC tagged with an :AB line tag:


NDELETE ABC ALL :AB


To NDELETE all unexcluded lines not containing the text “abc” as a prefix:


NDELETE ALL T'abc' PREFIX NX



Deleting all-blank lines with NDELETE


It is not possible to use DELETE to delete all blank lines. The reason is that a "blank" might have a variable number of space characters, or in a zero-length line there are no space characters at all. So, there is no specific string you could "search" for that would always be there.


The easiest way to delete blank lines is to use NDELETE instead of DELETE. Instead of trying to find "blank" lines, you find and then delete all lines which are not non-blank lines. 


People sometimes have issues with this, since it's like a "double negative", and not intuitive. Once you observe it in action, you'll see that it makes sense.


You can find non-blank lines by finding lines that contain  P'^' or  P'¬', which match non-blank characters. So, to delete all blank lines, you delete all lines which don't contain any non-blanks, like this:


NDELETE P'^' ALL


Be sure to specify  NDELETE  and not  DELETE. If you say  DELETE P'^' ALL, you will delete every line in the file that is not blank. In other words, you will have just deleted all of your data!


If you dont' care for the "double negative" appearance of this command, you can define a SET variable that's easier to remember. Let's say we call this variable DBLANK. You define it like this (the outer quotes are required):


       SET DBLANK = "NDELETE P'^'"


Then when you want to delete all blank lines, you would do it like this:


       =DBLANK ALL

 

You can create a command alias so that the leading = sign is not needed. To do this, define the DBLANK command like this:


       SET ALIAS.DBLANK = "NDELETE P'^'"


Then when you want to exclude all blank lines, you would do it like this:


       DBLANK ALL

Created with the Personal Edition of HelpNDoc: What is a Help Authoring tool?