Table of contents
CSPICE_LASTNB returns the integer value for the index of the final
non-blank (not a space) character in a character string.
Given:
string the input character string.
help, string
STRING = Scalar
the call:
lastnb = cspice_lastnb( string )
returns:
lastnb the zero-based index of the last non-blank character in a
character string.
help, lastnb
LONG = Scalar
If the string is entirely blank or is empty, the value -1 is
returned.
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) Given a set of strings, find the index of the last non-blank
character on each of them.
Example code begins here.
PRO lastnb_ex1
print, 'String : "01234567 "'
print, FORMAT='(" Index: ", I2)', $
cspice_lastnb( '01234567 ' )
print, 'String : " 01234567 "'
print, FORMAT='(" Index: ", I2)', $
cspice_lastnb( ' 01234567 ' )
print, 'String : " 01234567 "'
print, FORMAT='(" Index: ", I2)', $
cspice_lastnb( ' 01234567 ' )
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
String : "01234567 "
Index: 7
String : " 01234567 "
Index: 11
String : " 01234567 "
Index: 8
If the string is blank or empty, return -1. Otherwise, step backwards
from the end of the string, one character at a time, until
something other than a blank is found. Return the index of that
character within the string.
1) If the input argument `string' is undefined, an error is
signaled by the IDL error handling system.
2) If the input argument `string' is not of the expected type, or
it does not have the expected dimensions and size, an error is
signaled by the Icy interface.
None.
None.
ICY.REQ
None.
J. Diaz del Rio (ODC Space)
E.D. Wright (JPL)
-Icy Version 1.0.1, 27-AUG-2021 (JDR)
Edited the header to comply with NAIF standard. Added
example's problem statement and reformatted example's output.
Removed reference to 0-based indexing from -Abstracts as it
it present in the relevant argument description.
Added -Parameters, -Exceptions, -Files, -Restrictions,
-Literature_References and -Author_and_Institution sections, and
completed -Particulars section.
Removed reference to the routine's corresponding CSPICE header from
-Abstract section.
Added arguments' type and size information in the -I/O section.
-Icy Version 1.0.0, 16-JUN-2003 (EDW)
last non-blank character
|