Swap V5.0
Current Version: V5.0.0
Itanium Version: V5.1.0

Swap V5.1 is now available for downloading to install Swap on Itanium systems running OpenVMS V8.2 or higher. Customers should continue to install and run V5.0 on AXP and VAX systems; they are functionally equivalent and Swap V5 and Cohort V4 licenses will work for versions once an AXP compile of Swap V5.1 is available for installation. Download installation instructions here.
Download swap50.zip here. SwapV5 can be downloaded and installed on any VAX or AXP system running OpenVMS 6.1 or higher. Should you require a compiled version for OpenVMS 5.4, 5.5 or 6.0 please contact us and we can build that kit for you. It should be unzipped on the VAX or AXP and then installed using VMSINSTAL; a complete set of release notes and installation instructions are included in the kit - use the VMSINSTAL OPTION N to access this file.
The Swap V5 user manual can be downloaded here; swapv50.pdf.

Release Notes
Swap V5 includes the ability to perform search and replace operations on more than one string at a time; previously only one operation could be performed at a time. From the DCL level up to three search and replace pairs maybe specified on the command line. The substitutions take place, in order, on each line of all files selected during processing. The new command syntax:

$ swap /qualifier filename.type searchstring1 substitution1 searchstring2 substitution2 searchstring3 substitution3

all the previously available qualifiers for controlling swaps' operation are still available and work as previously documented.

Swap V5 can now open and perform substitutions on three common files structures found in OpenVMS. These structures are sequential with variable record lengths, stream_lf (stream format with lf separators) and stream (stream format without separators). The two stream formats are the most common format for files that have been downloaded or ftped to the VAX or AXP from a PC or the internet. Previous versions of Swap could only open sequential files.
The search and replace string(s) can now be in a file. The /substitutions qualifier directs SWAP to read the search and replace string(s) from that file. The filename will default to directory swap_dir: and type .sub if these portions are omitted. The format is search string on one line and replace string on the next line; any line beginning with an exclamation point "!" will be treated as a comment and skipped. The strings are read in as is but if they contain trailing spaces they should be enclosed in double quotes. If the first and last characters of a string are double quotes these double quotes will be removed. An example file (reformat_data):

! reformat_data substitutions file for SWAP
! first remove commas from the data lines

! next insert a line number at the beginning of the line

! finally reformat our data line, splitting it into two lines

on body text in file general.txt:
person 1           ,dept 1,Human Resources Dept.
person 2           ,dept 2,Contract Administration

$ swap general.txt /subs=reformat_data /column=(1,1)
would result in
01000person 1           
01000dept 1Human Resources Dept.
01100person 2
01100dept 2Contract Administration

NB: When working with variables to reformat a line using /column=(1,1) guarantees that the reformatting is only performed once on each line.

The menu has been updated to allow input of up to three search and replace pairs and substitutions are performed exactly as they are from the DCL level. The menu has not been updated to handle substitutions files since it is considered likely that they would primarily be used in batch jobs.

It is now possible when processing variables to include the same variable multiple times in the output record. This provides an easy way to reformat records and duplicate fields if required.

It is now possible to include the double quote character (") in search and replace strings. Previously, since this character is used by DCL, including it would result in unusual parsing of the command line. To search for a double quote it must be included in a quoted string and, like DCL, you must include two to indicate one literal double quote. For example, to remove all double quotes from a file you would use the following command:

$ Swap file.file_type """" ""  ! four double quotes - space - two double quotes for null string

Because DCL determines the end of a string by finding the first double quote followed by a space after it encounters an opening double quote you cannot search for double quotes followed by spaces. DCL will incorrectly parse the search and replace strings. If this is an issue you can still use Swap to perform the substitution by replacing all double quote characters with an unused character (~ or | are both potential characters), making the required substitution and then turning any of the unused characters that remain back to double quotes. Alternatively it is very easy to reformat data lines using Swap variables.

It is now possible to insert text into a file without performing a substitution. Previously if the search string was empty an error was reported. Now if the search string is empty the replacement string will be inserted into each record; this will work with text strings or a numeric variable for inserting sequential numbers into the output record. To prevent unexpected results be sure to specify /column=(x,x) where x is the column number the text is to be inserted at. For example to number all the records in a file followed by a comma:

$ swap filename.type "" "%5Z5,1,1%," /column=(1,1)

if the numeric value was to be inserted at column 25 "/column=(25,25)". The rest of the data record, before and/or after, the inserted text will be copied as is. To append text to the end of the line you must use a variable to hold the line and pad it to the specified length if the record is shorter (assume the maximum record length is currently 75 characters):

$ swap filename.type "%a75%" "%a%,%5Z5,1,1%" /column=(1,1)

If the variable is not used to hold the data line records shorter than the maximum record length of the input file may not be updated. In this case we have included column=(1,1) so that the record is reformatted only once - if /column was not included it could be reformated once for every character in the original record with unpredictable results.

Several minor problems with variable processing were discovered during testing. These problems had not been reported by existing customers but have been corrected.