Table of contents
CSPICE_REPMC replaces a marker with a character string.
Given:
in an arbitrary character string.
help, in
STRING = Scalar
marker an arbitrary character string.
help, marker
STRING = Scalar
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 or empty.
value the replacement character string.
help, value
STRING = Scalar
Leading and trailing blanks in `value' are NOT significant:
the portion of `value' that is substituted for `marker'
extends from its first non-blank character to its last
non-blank character.
However, if `value' is blank or empty, a single blank is
substituted for the first occurrence of `marker'.
the call:
cspice_repmc, in, marker, value, out
returns:
out the string obtained by substituting `value' (leading and
trailing blanks excepted) for the first occurrence of `marker'
in the input string.
help, out
STRING = Scalar
None.
Any numerical results shown for this example may differ between
platforms as the results depend on the SPICE kernels used as input
and the machine specific arithmetic implementation.
1) The following example illustrate the use of cspice_repmc to
replace a marker within a string with a character string
value.
Example code begins here.
PRO repmc_ex1
;;
;; 1. Single marker
;;
marker = '#'
instr = 'Invalid value. The value was: #'
cspice_repmc, instr, marker, 'append', outstr
print, 'Case 1: Single marker.'
print, ' Input : ', instr
print, ' Output: ', outstr
print
;;
;; 2. Multiple markers
;;
marker = ' XX '
instr = 'The token XX was not recognized. Was it XX?'
cspice_repmc, instr, marker, ' FND ', outstr
print, 'Case 2: Multiple markers.'
print, ' Input : ', instr
print, ' Output: ', outstr
print
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
Case 1: Single marker.
Input : Invalid value. The value was: #
Output: Invalid value. The value was: append
Case 2: Multiple markers.
Input : The token XX was not recognized. Was it XX?
Output: The token FND was not recognized. Was it XX?
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
cspice_repmct, string, '#1', n_pics, 'C', string
cspice_repmc, string, '#2', DIR_NAME, 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.
cspice_repmc ( Replace marker with character string value )
cspice_repmd ( Replace marker with double precision value )
cspice_repmf ( Replace marker with formatted d.p. value )
cspice_repmi ( Replace marker with integer value )
cspice_repml ( Replace marker with logical value )
cspice_repmct ( Replace marker with cardinal text )
cspice_repmot ( Replace marker with ordinal text )
1) If `marker' is blank or empty, or if `marker' is not a substring of
`in', no substitution is performed. (`out' and `in' are identical.)
2) If `value' is blank or empty, a single blank is substituted for the
first occurrence of `marker'.
3) If any of the input arguments, `in', `marker' or `value', is
undefined, an error is signaled by the IDL error handling
system.
4) If any of the input arguments, `in', `marker' or `value', is
not of the expected type, or it does not have the expected
dimensions and size, an error is signaled by the Icy
interface.
5) If the output argument `out' is not a named variable, an error
is signaled by the Icy interface.
None.
None.
ICY.REQ
None.
J. Diaz del Rio (ODC Space)
-Icy Version 1.0.0, 01-JUN-2021 (JDR)
replace marker with character_string
|