replwd |
Table of contents
ProcedureREPLWD ( Replace a word ) SUBROUTINE REPLWD ( INSTR, NTH, NEW, OUTSTR ) AbstractReplace the Nth word in a string with a new word. Required_ReadingNone. KeywordsASSIGNMENT WORD DeclarationsIMPLICIT NONE CHARACTER*(*) INSTR INTEGER NTH CHARACTER*(*) NEW CHARACTER*(*) OUTSTR Brief_I/OVARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- INSTR I Input string. NTH I Number of the word to be replaced. NEW I Replacement word. OUTSTR O Output string. Detailed_InputINSTR is the input character string, possibly containing one or more words, where a word is any string of consecutive non-blank characters delimited by a blank or by either end of the string. NTH is the number of the word to be replaced. Words are numbered from one. If NTH is less than one, or greater than the number of words in the string, no replacement is made. NEW is the word which is to replace the specified word in the input string. Leading and trailing blanks are ignored. If the replacement word is blank, the original word is simply removed. Detailed_OutputOUTSTR is the output string. This is the input string with the N'th word replaced by the word NEW. Any blanks originally surrounding the replaced word are retained. OUTSTR may overwrite INSTR. ParametersNone. ExceptionsError free. 1) If NEW is blank, then the Nth word is replaced by a single space. FilesNone. ParticularsThe effect of this routine is to remove the old word with REMSUB, and insert the replacement word with INSSUB. ExamplesLet INSTR = ' Woodsy is the Anti-Pollution Owl.' and NEW = ' an ' then the following values of NTH yield the following strings. NTH OUTSTR --- ------------------------------------------ -1 ' Woodsy is the Anti-Pollution Owl.' 0 ' Woodsy is the Anti-Pollution Owl.' 1 ' an is the Anti-Pollution Owl.' 3 ' Woodsy is an Anti-Pollution Owl.' 4 ' Woodsy is the an Owl.' 5 ' Woodsy is the Anti-Pollution an' 6 ' Woodsy is the Anti-Pollution Owl.' Note that in the first, second, and last cases, the string was not changed. Note also that in the next to last case, the final period was treated as part of the fifth word in the string. If NEW is ' ', and NTH is 3, then OUTSTR = ' Woodsy is Anti-Pollution Owl.' RestrictionsNone. Literature_ReferencesNone. Author_and_InstitutionN.J. Bachman (JPL) J. Diaz del Rio (ODC Space) H.A. Neilan (JPL) W.L. Taber (JPL) I.M. Underwood (JPL) VersionSPICELIB Version 1.1.0, 12-AUG-2021 (JDR) Added IMPLICIT NONE statement. Edited the header to comply with NAIF standard. Removed unnecessary $Revisions section. SPICELIB Version 1.0.1, 10-MAR-1992 (WLT) Comment section for permuted index source lines was added following the header. SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) (WLT) (HAN) (NJB) |
Fri Dec 31 18:36:43 2021