repmi_c

Index Page repmi_c
A B C D E F G H I J K L M N O P Q R S T U V W X
Procedure Abstract Required_Reading Keywords Brief_I/O Detailed_Input | Detailed_Output Parameters Exceptions Files Particulars Examples | Restrictions Literature_References Author_and_Institution Version Index_Entries
#### Procedure
       void repmi_c ( ConstSpiceChar     * in,
                      ConstSpiceChar     * marker,
                      SpiceInt             value,
                      SpiceInt             lenout,
                      SpiceChar          * out     )
#### Abstract
       Replace a marker with an integer.
#### Required_Reading
       None.
#### Keywords
       CHARACTER
       CONVERSION
       STRING
#### Brief_I/O
       VARIABLE  I/O  DESCRIPTION
       --------  ---  --------------------------------------------------
       in         I   Input string.
       marker     I   Marker to be replaced.
       value      I   Replacement value.
       lenout     I   Available space in output string.
       out        O   Output string.
       MAXLI      P   Maximum length of an integer.
#### Detailed_Input
       in             is an arbitrary character string.

       marker         is an arbitrary character string. The first occurrence
                      of marker in the input string is to be replaced by value.

                      Leading and trailing blanks in marker are NOT significant.
                      In particular, no substitution is performed if marker
                      is blank.

       value          is an arbitrary integer.

       lenout         is the allowed length of the output string.  This length
                      must large enough to hold the output string plus the
                      terminator.  If the output string is expected to have x
                      characters, lenout should be at least x + 1.
#### Detailed_Output
       out            is the string obtained by substituting the text
                      representation of value for the first occurrence
                      of marker in the input string.

                      out and in must be identical or disjoint.
#### Parameters
       MAXLI          is the maximum expected length of the text
                      representation of an integer. 11 characters are
                      sufficient to hold any integer whose absolute
                      value is less than 10 billion.

                      This routine assumes that the input integer
                      is such that its string representation contains
                      no more than MAXLI characters.
#### Exceptions
       1) The error SPICE(NULLPOINTER) is signaled if any of
          the input or output string pointers is null.

       2) If the marker string is blank or empty, this routine leaves
          the input string unchanged, except that trailing blanks
          will be trimmed.  This case is not considered an error.

       3) If the output string is too short to accommodate a terminating
          null character, the error SPICE(STRINGTOOSHORT) is signaled.

       4) If out does not have sufficient length to accommodate the
          result of the substitution, the result will be truncated on
          the right.
#### Files
       None.
#### Particulars
       This is one of a family of related routines for inserting values
       into strings. They are typically to construct messages that
       are partly fixed, and partly determined at run time. For example,
       a message like

          "Fifty-one pictures were found in directory [USER.DATA]."

       might be constructed from the fixed string

          "#1 pictures were found in directory #2."

       by the calls

          #include "SpiceUsr.h"
               .
               .
               .
          #define   LENOUT                  81
               .
               .
               .
          repmct_c ( string, "#1",  51,  'c',      LENOUT, string );
          repmc_c  ( string, "#2", "[USER.DATA]",  LENOUT, string );

       which substitute the cardinal text "Fifty-one" and the character
       string "[USER.DATA]" for the markers "#1" and "#2" respectively.

       The complete list of routines is shown below.

          repmc_c  ( Replace marker with character string value )
          repmd_c  ( Replace marker with double precision value )
          repmf_c  ( Replace marker with formatted d.p. value   )
          repmi_c  ( Replace marker with integer value          )
          repmct_c ( Replace marker with cardinal text          )
          repmot_c ( Replace marker with ordinal text           )
#### Examples
       1. Let

             in == "Invalid operation value.  The value was <opcode>."

          Then following the call,

             #include "SpiceUsr.h"
                  .
                  .
                  .
             #define   LENOUT                  201
                  .
                  .
                  .
             repmi_c ( in, "<opcode>", 5, LENOUT, outstr );

          outstr contains the string:

             "Invalid operation value.  The value was 5."

       2. Let

             in ==  "Left endpoint exceeded right endpoint.  "
                    "The left endpoint was:  XX.  The right "
                    "endpoint was:  XX."

          Then following the call,

             #include "SpiceUsr.h"
                  .
                  .
                  .
             #define   LENOUT                  201
                  .
                  .
                  .
             repmi_c ( in, "  XX  ", 5, LENOUT, out );

          out is

             "Left endpoint exceeded right endpoint.  The left "
             "endpoint was:  5.  The right endpoint was:  XX."

       3. Let

             num    == 23
             chance == "fair"
             score  == 4.665

          Then following the sequence of calls,

             #include "SpiceUsr.h"
                  .
                  .
                  .
             #define   LENOUT                  201
                  .
                  .
                  .
             repmi_c ( "There are & routines that have a "
                       "& chance of meeting your needs."
                       "The maximum score was &.",
                       "&",
                        num,
                        LENOUT,
                        msg                              );

             repmc_c ( msg, marker, chance, LENOUT, msg );

             repmf_c ( msg, marker, score,  4, 'f', LENOUT, msg );

          msg is

             "There are 23 routines that have a fair chance of "
             "meeting your needs.  The maximum score was 4.665."
#### Restrictions
       None.
#### Literature_References
       None.
#### Author_and_Institution
       N.J. Bachman   (JPL)
       I.M. Underwood (JPL)
#### Version
       -CSPICE Version 1.0.0, 14-AUG-2002 (NJB) (IMU)
#### Index_Entries
       replace marker with integer
#### Link to routine repmi_c source file repmi_c.c

    Thu Apr 16 08:59:00 2009