Introduction
This page provides a basic overview of how SWAP works.  SWAP commands have the form:

SWAP [/qualifier] file_specification search_string replacement_string

File specification
The file_specification parameter designates one or more files to be changed.  This parameter is mandatory. In the menu enter this parameter on the Search & Replace Menu.

Search string
The search_string parameter specifies the string to look for.  This parameter is mandatory.  It may be null. In the menu enter this parameter on the Search & Replace Menu.

Replacement string
The replacement_string parameter specifies the string that replaces the search_string.  This parameter is mandatory.  It may be null. In the menu enter this parameter on the Search & Replace Menu.

Qualifiers
You control the search and replacement operation using qualifier such as /EXACT and /RANGE.

The following chapters describe the parameters in more detail.  Syntax examples are contained in the chapter on commands.

Specifying Files
SWAP allows you to make a change to a group of input files.  This chapter describes how to specify sets of files to be processed by SWAP.

Node
The file specification CANNOT contain a node specification.

Devices and Directories
The file specification can contain normal OpenVMS device and directory specifications such as:

"DUA0:[SWAP.SRC]*.FOR"

If device and directory aren't specified, the existing user defaults are used.

Logical Names
The file specification can contain logical names in place of the device and directory specification.  For example:

"USER$DISK1:*.COB".

Using a File List
You can specify a list of files by separating the names with commas.  Here's a sample:

MAIN.FOR,EXTRACT.FOR,REPORT.FOR,COLLECT.FOR

Wildcards
You can use standard OpenVMS wildcard specifications in the file specifications.  For example, "*.FOR" specifies all FORTRAN source programs and "SYS%A.MAR" will select MACRO source such as SYS1A.MAR, SYS2A.MAR, etc.  For more information about wildcards, refer to the OpenVMS DCL concepts manual.

NOTE:  Use expressions such as *.FOR or *.COB or *.RNO rather than *.* unless you are sure everything in the directory is an ASCII text file.  SWAP does NOT check that input files are ASCII text files before attempting to process them.

Extentions
SWAP does NOT assume "*" if the file extension is omitted.  If you don't specify any file extension, SWAP will search for the file name with no extension (ie TEMP.;).  If it is not found, an informational message is displayed on the screen saying the file was not found.

Excluding Files
You can specify a group of files then exclude specific files in the group using the /EXCLUDE qualifier.  For example,

    $ SWAP/EXCLUDE=MAIN.FOR *.FOR

selects all FORTRAN programs except MAIN.FOR.  The exclude list can contain more than one file if you enclose the names in brackets "()" and separate them with commas.  Wildcards are allowed.

Specifying Strings
SWAP looks for a search string in the input files and substitutes a replacement string if one has been specified.  This chapter describes how to specify search and replacement strings.


String Specification

Maximum Length
Maximum string length is 255 characters.  This applies to both the search and replacement strings. The maximum string length for the menu is significantly smaller.

Embedded Blanks
If a string contains leading, trailing or embedded blanks, you must enclose the string in quotes such as "THIS STRING CONTAINS EMBEDDED BLANKS".  If the string consists of a single word, quotes are not necessary but it will be converted to uppercase.

Case
SWAP will automatically convert all strings to UPPERCASE unless you enclose them in quotes.

Null Strings
A null string is entered by entering two quotes together ("").  Both the search and replacement strings can be null.

Special Characters
To enter special characters use the format %Xnn or %Dnnn where "%" designates a special character, "X" or "D" indicates hexadecimal or decimal and "nn" contains a hexadecimal or decimal value.  For example the following command removes the ASCII LINE FEED character:

    $ SWAP *.TXT %D010 ""

Here's another example which replaces the ASCII FORM FEED character with the string ".PAGE" character:

    $ SWAP *.RNO %X0C ".page"

A table of ASCII characters with their decimal and hexadecimal values is contained in an appendix at the end of this manual. Special characters may be entered this way through the menu interface as well.

NOTE:  Special character strings are limited to 1 character only.  They must start with the character "%".  The special character specification may be enclosed in quotes (ie "%D010").  If a string contains a special character specification at the beginning of the string, it will be interpreted as a special character (ie "%X20abcd" _ this will be interpreted as a special character and the "abcd" will be ignored).

Search String
The search string must be present.  It may be null (when the /TAB or /LENGTH qualifiers are used and no string substitutions are required).

Replacement String
The replacement string must be present.  It can be null, shorter than, equal to or longer than the search string.  If the replacement string is null, the search string is removed from the files.

You can specify a special character in the replacement string as well as the search string.