Index of Functions: A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X 
Index Page
cspice_cmprss

Table of contents
Abstract
I/O
Parameters
Examples
Particulars
Exceptions
Files
Restrictions
Required_Reading
Literature_References
Author_and_Institution
Version
Index_Entries


Abstract


   CSPICE_CMPRSS compresses a character string by truncating
   occurrences of more than 'n' consecutive occurrences of a
   specified character to 'n' occurrences.

I/O


   Given:

      delim    the delimiter to be compressed out of the string.

               help, delim
                  STRING = Scalar

               This may be any ASCII character.

      n        the maximum number of consecutive occurrences of `delim' that
               will be allowed to remain in the output string.

               help, n
                  LONG = Scalar

      input    the input string.

               help, input
                  STRING = Scalar

               The routine allocates memory for the `output' string based on
               the length of the `input' string. An `input' string with length
               zero is an no-op.

   the call:

      cspice_cmprss, delim, n, input, output

   returns:

      output   the output string.

               help, output
                  STRING = Scalar

               This is the input string with all occurrences of more than `n'
               consecutive delimiters removed.

               `output' may overwrite `input'.

Parameters


   None.

Examples


   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) Remove multiple occurrences of a character in different strings.
      As example, compress the occurrences of '.' down to two periods
      (..), three periods (...) or just one period (.). Also, as a
      practical example, remove trailing, leading and embedded spaces
      from an input string.

      Example code begins here.


      PRO cmprss_ex1

         strings = [ 'ABC...DE.F...',  $
                     '...........',   $
                     '.. ..AB....CD' ]

         ;;
         ;; Compress multiple occurrences of '.'
         ;; in the strings array. Compress to
         ;; two periods...
         ;;
         cspice_cmprss, '.', 2, strings[0], output
         print, 'Input : `', strings[0], '`'
         print, 'Output: `', output, '`'
         print, ''

         ;;
         ;; ...three periods...
         ;;
         cspice_cmprss, '.', 3, strings[1], output
         print, 'Input : `', strings[1], '`'
         print, 'Output: `', output, '`'
         print, ''

         ;;
         ;; ...one period.
         ;;
         cspice_cmprss, '.', 1, strings[2], output
         print, 'Input : `', strings[2], '`'
         print, 'Output: `', output, '`'
         print, ''

         ;;
         ;; Use the call to remove trailing, leading, and
         ;; embedded spaces.
         ;;
         cspice_cmprss, ' ', 0, ' Embe dde d -sp   a c  es   ', output
         print, 'Input : ', '` Embe dde d -sp   a c  es   `'
         print, 'Output: `', output, '`'

      END


      When this program was executed on a Mac/Intel/IDL8.x/64-bit
      platform, the output was:


      Input : `ABC...DE.F...`
      Output: `ABC..DE.F..`

      Input : `...........`
      Output: `...`

      Input : `.. ..AB....CD`
      Output: `. .AB.CD`

      Input : ` Embe dde d -sp   a c  es   `
      Output: `Embedded-spaces`


Particulars


   Occurrences of more than `n' consecutive delimiters are removed
   from the input string as it is copied to the output string.

   IDL native code to perform the same operation (whitespace only):

      Remove all instances of a whitespace.
      output = strcompress( input, /REMOVE_ALL )

      Remove all but one instance of a whitespace.
      output = strcompress( input )

   Note: strcompress accepts vector arguments.

Exceptions


   1)  If any of the input arguments, `delim', `n' or `input', is
       undefined, an error is signaled by the IDL error handling
       system.

   2)  If any of the input arguments, `delim', `n' or `input', is not
       of the expected type, or it does not have the expected
       dimensions and size, an error is signaled by the Icy
       interface.

   3)  If the output argument `output' is not a named variable, an
       error is signaled by the Icy interface.

Files


   None.

Restrictions


   None.

Required_Reading


   ICY.REQ

Literature_References


   None.

Author_and_Institution


   J. Diaz del Rio     (ODC Space)
   E.D. Wright         (JPL)

Version


   -Icy Version 1.0.1, 31-MAY-2021 (JDR)

       Edited the header to comply with NAIF standard. Added example's
       problem statement and reformatted example's output.

       Added -Parameters, -Particulars, -Exceptions, -Files, -Restrictions,
       -Literature_References and -Author_and_Institution sections.

       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)

Index_Entries


   compress a character_string



Fri Dec 31 18:43:02 2021