REPLACE

[ Program Manual | User's Guide | Data Files | Databases ]

Table of Contents
FUNCTION
DESCRIPTION
EXAMPLE
OUTPUT
RELATED PROGRAMS
RESTRICTIONS
INPUT FILE
COMMAND-LINE SUMMARY
LOCAL DATA FILES
PARAMETER REFERENCE

FUNCTION

[ Top | Next ]

Replace makes character string replacements in text file(s). You provide a table of replacements in a file showing each existing string and its replacement.

DESCRIPTION

[ Previous | Top | Next ]

Replace reads existing strings and replacement strings from a file of replacements. Replace reads each line of each file you want to modify. It searches for the existing strings and replaces them with the replacement strings. The existing and replacement strings can have different lengths, and any character can be put in either string. The replacements are made to each line in the order of occurrence in the file of replacements. Replace writes a new version of each modified file in the same directory as the old files. The new files have the same name as the old files unless you use the command-line parameter -EXTension. If you use the -EXTension command-line parameter, the new files are written in your local directory.

EXAMPLE

[ Previous | Top | Next ]

Here is a session using Replace to convert a file of FORTRAN source code to our new coding standard:


% replace

  REPLACE in what file(s) ?  cmpvals.for

  What replacement file ?  GenDocData:procedure.replace

  What should I call the output file (* cmpvals.for *) ?

  REPLACE complete with:

         Files modified: 1
     Total Replacements: 29

%

OUTPUT

[ Previous | Top | Next ]

The output files have the same names and look exactly like the input files except for the strings that were replaced.

RELATED PROGRAMS

[ Previous | Top | Next ]

Replace, CompressText, OneCase, ShiftOver, DeTab, ChopUp, LPrint, and ListFile are the Wisconsin Package file utilities programs.

RESTRICTIONS

[ Previous | Top | Next ]

Replace is record oriented -- the strings you want to replace must be found on the same line. The replacements are made in the order of the replacements specified in the file of replacements. You cannot have more than 1,000 different replacements. Lines may be elongated by the replacements, but Wisconsin Package programs cannot read or write lines longer than 511 characters!

INPUT FILE

[ Previous | Top | Next ]

After an introductory text heading, the strings that you want to replace and the strings that you want to replace them with are enclosed in double quotation marks. The existing and replacement strings must be on the same line. If you want to use a double quotation mark inside an existing or replacement string, simply use two double quotes in a row to represent one. If you want to require that the search for some, but not all, of the existing strings be case sensitive, you can add a 'C' after the replacement string on those lines where you want a case-sensitive search. If you only want to replace the existing string if it occurs in a particular column add the column number after the replacement string.

As in all Wisconsin Package data files, comments can follow an '!' (exclamation) character on any line and blank lines are allowed. Here is a small part of the file of replacements used for example session:


A file of replacements used for the example session with REPLACE and to
make old GCG Fortran source code compatible with the C programming
language.

"Existing string"       "Replacement string"  ..

" BEEP"                " RingBell"

! changes FPRINTF AND SPRINTF

"PRINTF"               "WriteF"

! changes SSCANF AND FSCANF

"SCANF"                "ReadF"

"WGETCHARVECTORS"      "WGetHersheyVectors"
"GETCH"                "Get_Ch"

"ISBLACK"              "ChIsBlack"
"ISUWGCG"              "ChIsGCG"

! changes STRISUPPER AND STRISLOWER

"       ISLOWER"        "       ChIsLower"
" ISLOWER"              " ChIsLower"
".ISLOWER"              ".ChIsLower"
"(ISLOWER"              "(ChIsLower"
",ISLOWER"              ",ChIsLower"

" call "               " Call "                     C
"       call "         "        Call "              C

! try to make the module headers more consistent

"***  "                "!***  "                     1
"c **    "             "!*"                         1

! the continuation character for FORTRAN 88

"     * "              "     & "                    1
"     * "              "     &  "                   1

/////////////////////////////////////////////////////

COMMAND-LINE SUMMARY

[ Previous | Top | Next ]

All parameters for this program may be added to the command line. Use -CHEck to view the summary below and to specify parameters before the program executes. In the summary below, the capitalized letters in the parameter names are the letters that you must type in order to use the parameter. Square brackets ([ and ]) enclose parameter values that are optional. For more information, see "Using Program Parameters" in Chapter 3, Using Programs in the User's Guide.


Minimal Syntax:  % replace [-INfile=]cmpvals.for \
                   [-Repfile=]GenDocData:procedure.replace -Default

Prompted Parameters:

[-OUTfile=]cmpvals.for  names output file
                          (only when the input file name is NOT ambiguous)

Local Data Files: None

Optional Parameters:

-CASe                does a case-sensitive search for all existing strings
-TRAce[=filename]    shows lines with replacements on your screen or
                       in a file
-EXTension=.replace  resets the file name extension on the output files
-NOMONitor           suppresses the screen monitor
-NOSUMmary           suppresses the screen summaries

LOCAL DATA FILES

[ Previous | Top | Next ]

None.

PARAMETER REFERENCE

[ Previous | Top | Next ]

You can set the parameters listed below from the command line. For more information, see "Using Program Parameters" in Chapter 3, Using Programs in the User's Guide.

-CASe

Usually, Replace does a case-independent search for the existing strings that you want to replace. You can restrict that search to find only strings that match in case as well as in characters with this parameter. You can specify a case-dependent search for any particular existing string by adding a 'C' after the replacement string in the replacement file.

-TRAce=filename

For any line with a replacement, Replace prints the old line and the new line on your terminal screen. This parameter also displays the information from your replacement file. If you supply a value for filename, this parameter will write the tracing information into a file instead of on your terminal screen.

-EXTension=.replace

Usually, Replace uses the input file names as the names for the output files. Use this parameter without the optional value to indicate that the output file name extension should be .replace instead of the original file name extension. To designate a different extension, type it as the value for this parameter. If you use this parameter, the output files are written in your local directory .

-MONitor

This program normally monitors its progress on your screen. However, when you use -Default to suppress all program interaction, you also suppress the monitor. You can turn it back on with this parameter. If you are running the program in batch, the monitor will appear in the log file.

-SUMmary

writes a summary of the program's work to the screen when you've used -Default to suppress all program interaction. A summary typically displays at the end of a program run interactively. You can suppress the summary for a program run interactively with -NOSUMmary.

You can also use this parameter to cause a summary of the program's work to be written in the log file of a program run in batch.

Printed: December 9, 1998 16:29 (1162)

[ Program Manual | User's Guide | Data Files | Databases ]


Documentation Comments: doc-comments@gcg.com
Technical Support: help@gcg.com

Copyright (c) 1982-2001 Genetics Computer Group, Inc. A subsidiary of Pharmacopeia, Inc. All rights reserved.

Licenses and Trademarks Wisconsin Package is a trademark of Genetics Computer Group, Inc. GCG and the GCG logo are registered trademarks of Genetics Computer Group, Inc.

All other product names mentioned in this documentation may be trademarks, and if so, are trademarks or registered trademarks of their respective holders and are used in this documentation for identification purposes only.

Genetics Computer Group

www.gcg.com