Table of contents
CSPICE_ISWHSP returns a boolean indicating whether an input string contains
only whitespace characters (true) or not (false).
Given:
string a string to be searched for non-white-space characters.
help, string
STRING = Scalar
the call:
iswhsp = cspice_iswhsp( string )
returns:
iswhsp the boolean value true if the string contains only white space
characters; otherwise it returns the value false.
help, iswhsp
BOOLEAN = Scalar
White space characters are those in the set
{ ' ', '\f', '\n', '\r', '\t', '\v' }
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) Check, for different input character strings, if they contain
only whitespace characters.
Example code begins here.
PRO iswhsp_ex1
;;
;; A single space signals the whitespace flag...
;;
print, 'Single space: '
if ( cspice_iswhsp( ' ' ) ) then print, ' Whitespace' $
else print, ' Not whitespace.'
;;
;; ...but a non-whitespace character in a string with a
;; whitespace does not.
;;
print, 'A non-whitespace character in string with whitespaces: '
if ( cspice_iswhsp( ' x' ) ) then print, ' Whitespace' $
else print, ' Not whitespace.'
;;
;; A combination of whitespace and non-whitespace.
;;
print, 'Combination of whitespace and non-whitespace: '
if ( cspice_iswhsp( ' a b c ' ) ) then print, ' Whitespace' $
else print, ' Not whitespace.'
;;
;; Multiple space characters signals the whitespace flag...
;;
print, 'Multiple space characters: '
if ( cspice_iswhsp( ' ' ) ) then print, ' Whitespace' $
else print, ' Not whitespace.'
;;
;; ...as does an empty string.
;;
print, 'Empty string: '
if ( cspice_iswhsp( '' ) ) then print, ' Whitespace' $
else print, ' Not whitespace.'
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
Single space:
Whitespace
A non-whitespace character in string with whitespaces:
Not whitespace.
Combination of whitespace and non-whitespace:
Not whitespace.
Multiple space characters:
Whitespace
Empty string:
Whitespace
Note: the Icy interface does not pass escaped whitespace
markers \t, \f, \r, \n, \v as whitespace. cspice_iswhsp
signals these string markers as non-whitespace.
This routine provides a short cut for testing lines for the presence
of non-blank characters; this is a test which is performed frequently
in Icy.
1) An empty string is considered to be blank.
2) If the input argument `string' is undefined, an error is
signaled by the IDL error handling system.
3) 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, 10-AUG-2021 (JDR)
Edited the header to comply with NAIF standard. Added example's
problem statement, and reformatted example's output.
Added -Parameters, -Exceptions, -Files, -Restrictions,
-Literature_References and -Author_and_Institution sections, and
completed -Particulars section.
Edited the -I/O section to comply with NAIF standard.
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)
read a non-blank line from a text file
|