Index of Functions: A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X 
Index Page
replwd

Table of contents
Procedure
Abstract
Required_Reading
Keywords
Declarations
Brief_I/O
Detailed_Input
Detailed_Output
Parameters
Exceptions
Files
Particulars
Examples
Restrictions
Literature_References
Author_and_Institution
Version

Procedure

     REPLWD ( Replace a word )

     SUBROUTINE REPLWD ( INSTR, NTH, NEW, OUTSTR )

Abstract

     Replace the Nth word in a string with a new word.

Required_Reading

     None.

Keywords

     ASSIGNMENT
     WORD

Declarations

     IMPLICIT NONE

     CHARACTER*(*)    INSTR
     INTEGER          NTH
     CHARACTER*(*)    NEW
     CHARACTER*(*)    OUTSTR

Brief_I/O

     VARIABLE  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_Input

     INSTR    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_Output

     OUTSTR   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.

Parameters

     None.

Exceptions

     Error free.

     1)  If NEW is blank, then the Nth word is replaced by a single
         space.

Files

     None.

Particulars

     The effect of this routine is to remove the old word with
     REMSUB, and insert the replacement word with INSSUB.

Examples

     Let
           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.'

Restrictions

     None.

Literature_References

     None.

Author_and_Institution

     N.J. Bachman       (JPL)
     J. Diaz del Rio    (ODC Space)
     H.A. Neilan        (JPL)
     W.L. Taber         (JPL)
     I.M. Underwood     (JPL)

Version

    SPICELIB 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