Table of contents
CSPICE_REPML replaces a marker with the text representation of a logical
value.
Given:
in an arbitrary character string.
[1,c1] = size(in); char = class(in)
or
[1,1] = size(in); cell = class(in)
marker an arbitrary character string.
[1,c2] = size(marker); char = class(marker)
or
[1,1] = size(marker); cell = class(marker)
The first occurrence of `marker' in the input string is to
be replaced by `value'.
`marker' is case-sensitive.
Leading and trailing blanks in `marker' are NOT
significant. In particular, no substitution is
performed if `marker' is blank or empty.
value an arbitrary logical value, either true or false.
[1,1] = size(value); logical = class(value)
rtcase indicates the case of the replacement text.
[1,1] = size(rtcase); char = class(rtcase)
or
[1,1] = size(rtcase); cell = class(rtcase)
`rtcase' may be any of the following:
rtcase Meaning Output values
------ ----------- ---------------
U, u Uppercase 'TRUE', 'FALSE'
L, l Lowercase 'true', 'false'
C, c Capitalized 'True', 'False'
the call:
[out] = cspice_repml( in, marker, value, rtcase )
returns:
out the string obtained by substituting the text representation
of `value' for the first occurrence of `marker' in the input
string.
[1,c3] = size(out); char = class(out)
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 illustrates the use of cspice_repml to replace
a marker within a string with the text representation of a
logical value.
Example code begins here.
function repml_ex1()
%
% 1. Uppercase
%
marker = '#';
instr = 'Invalid value. The value was: #.';
[outstr] = cspice_repml( instr, marker, false, 'U' );
fprintf( 'Case 1: Replacement text in uppercase.\n' )
fprintf( ' Input : %s\n', instr )
fprintf( ' Output: %s\n', outstr )
fprintf( '\n' )
%
% 2. Lowercase
%
marker = ' XX ';
instr = 'Invalid value. The value was: XX.';
[outstr] = cspice_repml( instr, marker, true, 'l' );
fprintf( 'Case 2: Replacement text in lowercase.\n' )
fprintf( ' Input : %s\n', instr )
fprintf( ' Output: %s\n', outstr )
fprintf( '\n' )
%
% 2. Capitalized
%
marker = '#';
instr = 'Invalid value. The value was: #.';
[outstr] = cspice_repml( instr, marker, false, 'c' );
fprintf( 'Case 3: Replacement text capitalized.\n' )
fprintf( ' Input : %s\n', instr )
fprintf( ' Output: %s\n', outstr )
When this program was executed on a Mac/Intel/Octave6.x/64-bit
platform, the output was:
Case 1: Replacement text in uppercase.
Input : Invalid value. The value was: #.
Output: Invalid value. The value was: FALSE.
Case 2: Replacement text in lowercase.
Input : Invalid value. The value was: XX.
Output: Invalid value. The value was: true.
Case 3: Replacement text capitalized.
Input : Invalid value. The value was: #.
Output: Invalid value. The value was: False.
This is one of a family of related routines for inserting values
into strings. They are typically used 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
[tmpstr] = cspice_repmct( string, '#1', 51, 'C' );
[string] = cspice_repmc ( tmpstr, '#2', '[USER.DATA]' );
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 the value of `rtcase' is not recognized, the error
SPICE(INVALIDCASE) is signaled by a routine in the call tree
of this routine. `out' is not changed.
3) If any of the input arguments, `in', `marker', `value' or
`rtcase', is undefined, an error is signaled by the Matlab
error handling system.
4) If any of the input arguments, `in', `marker', `value' or
`rtcase', is not of the expected type, or it does not have the
expected dimensions and size, an error is signaled by the Mice
interface.
None.
None.
MICE.REQ
None.
J. Diaz del Rio (ODC Space)
-Mice Version 1.0.0, 23-JAN-2021 (JDR)
replace marker with logical value
|