This page gives a brief description of the SWAP utility. SWAP scans a set of ASCII files and replaces one string with another. For example, the command:
$ SWAP *.FOR "mxu" "maximum_users"
replaces all occurrences of the obscure variable name MXU with the more readable MAXIMUM_USERS in all FORTRAN source programs in the default directory.
SWAP combines the power of the SEARCH command with a sophisticated string substitution utility to produce an effective, easy to use software maintenance tool.
With the new variables feature added to V4 SWAP can also be used to reformat data files and/or generate and add a numeric value to the data lines.
File Set
Specify a list of files or select a group of files using wildcards. You can include device and directory information or use logical names. Use /EXCLUDE to omit special files
from the selected files.
Strings
The search string can be up to 255 characters long or null. It can contain leading or trailing blanks and both upper and lower case characters. The replacement string 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 files.
If you specify /EXACT, SWAP will consider UPPERCASE and lowercase as different characters in the search string. Otherwise, they will be considered the same.
You can limit the search to a particular range of lines within each file (/RANGE) or a particular set of columns within each record (/COLUMNS). Replacement can be automatic with /NOCONFIRM or prompted with /CONFIRM. If you specify /CONFIRM, each occurrence is displayed and you have the options:
Make the change
Ignore this substitution but continue searching the file
Ignore this file and continue with the rest of files
Abort the command
Help
Special Characters
If the files contain special characters, you can eliminate them or substitute printable characters using the "%" character to designate the decimal or hexadecimal value of special characters. For example,
$ SWAP *.RNO %X0C ".page"
would replace the ASCII FORM FEED character with the text string ".page". You can only perform one special character substitution per SWAP command.
Record Length
To specify a maximum output record length use /LENGTH. SWAP will truncate longer records to the length you specify. Shorter records will be left unchanged.
Remove Tabs
SWAP can replace TAB characters with blanks. By default SWAP replaces each TAB character with 8 blanks. You can change the number 8 to other values if you wish.
SWAP is easy to learn and use. It acts like an OpenVMS utility. SWAP commands look like normal DCL commands. It comes with complete documentation, on_line HELP and comprehensive OpenVMS_style error messages.
NOTE: SWAP requires OpenVMS V4.0 or later. No additional OpenVMS layered products or licenses are necessary.
Reformatting Records
SWAP V4 includes a new variable feature that supports quickly and easily reformatting data lines and/or generating and including a numeric value in the data lines of an output file. For a detailed explanation of how to use this feature refer to the section Using SWAP Variables on page .
SWAP Usage Summary
This chapter describes how to use SWAP.
Invoking SWAPs DCL Interface
To invoke SWAP, type SWAP at the command level along with the desired qualifiers and parameters.
DON'T DO THIS!
It is not necessary to assign a symbol such as $SWAP == "RUN SWAP.EXE". SWAP is defined as a command by the installation procedure. Defining a symbol like this may prevent SWAP from running.
Invoking SWAPs Menu Interface
To invoke SWAPs menu interface, type SWAP/MENU at the DCL level.
Help
Enter "HELP SWAP" at the command level to get help. Within the menu a help overview screen is available from the main menu. A helpful prompt is also displayed at the bottom of the menu screen for each item on the menu as you scroll/move through them.