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

Procedure
Abstract
Required_Reading
Keywords
Brief_I/O
Detailed_Input
Detailed_Output
Parameters
Exceptions
Files
Particulars
Examples
Restrictions
Literature_References
Author_and_Institution
Version
Index_Entries

Procedure

   void lx4dec_c ( ConstSpiceChar   * string,
                   SpiceInt           first,
                   SpiceInt         * last,
                   SpiceInt         * nchar  ) 

Abstract

 
   Scan a string from a specified starting position for the 
   end of a decimal number.  
 

Required_Reading

 
   None. 
 

Keywords

 
   PARSING 
 

Brief_I/O

 
   VARIABLE  I/O  DESCRIPTION 
   --------  ---  -------------------------------------------------- 
   string     I   Any character string.
   first      I   First character to scan from in string.
   last       O   Last character that is part of a decimal number.
   nchar      O   Number of characters in the decimal number. 
 

Detailed_Input

 
   string      is any character string. 
 
   first       is the location in the string to beginning scanning 
               for a decimal number.  It is assumed that the 
               decimal number begins at first.  

               The normal range of first is 0 : strlen(string)-1.
 

Detailed_Output

 
   last        is the last character at or after first such that the
               substring ranging from string[first] through
               string[last] is a decimal number.  If there is no such
               substring, last will be returned with the value first-1.

               If a decimal number is found, last will be in the
               range is 0 : strlen(string)-1.


   nchar       is the number of characters in the decimal number that
               begins at index first and ends at last.  If there is no
               such string nchar will be given the value 0.
 

Parameters

 
   None. 
 

Exceptions

  
   1) If first is beyond either end of the string, then 
      last will be returned with the value first-1 and nchar 
      will be returned with the value 0. 
 
   2) If string[first] is not part of a decimal number then last 
      will be returned with the value first-1 and nchar will be 
      returned with the value 0. 

   3) If the input string pointer is null, the error SPICE(NULLPOINTER)
      will be signaled.

   4) If the input string has length zero, last will be set to first-1
      and nchar will be set to zero.  This case is not considered an
      error.
 

Files

 
   None. 
 

Particulars

 
   This routine allows you to scan forward in a string to locate 
   a decimal number that begins on the input character first.  Note 
   that all signed integers are included in the list of decimal 
   numbers.  See lx4sgn_c for a description of signed integers. 
 
   We let S stand for a signed integer and U stand for 
   an unsigned integer.  With this notation, the strings 
   recognized as decimal numbers are: 
 
      U 
      S 
      S. 
      S.U 
       .U 
      -.U 
      +.U 
 
 

Examples

 
   1) Suppose you believe that a string has the form 
 
         X%Y%Z 
 
      where X, Y, and Z are decimal numbers of some unknown length and
      % stands for any character that cannot occur in a decimal number.
      You could use this routine to locate the decimal numbers in the
      string as shown below.  We'll keep track of the beginning and
      ending of the decimal numbers in the integer arrays b and e.
 

         #include <string.h>
         #include "SpiceUsr.h"

               .
               .
               .

         first = 0;
         i     = 0;
         len   = strlen(string);

         while ( first < len-1 )
         {
            lx4dec_c ( string, first, &last, &nchar );

            if ( nchar > 0 )
            {
               i++;

               b[i]  = first;
               e[i]  = last;
               first = last  +  2;
            }
            else
            {
               first++;  
            }
         }
          

Restrictions

 
   None. 
 

Literature_References

 
   None. 
 

Author_and_Institution

 
   N.J. Bachman    (JPL)
   W.L. Taber      (JPL) 
 

Version

 
   -CSPICE Version 1.0.0, 18-AUG-2002 (NJB) (WLT)

Index_Entries

 
   Scan a string for a decimal number. 
 
Wed Apr  5 17:54:38 2017