lx4dec |
Table of contents
ProcedureLX4DEC (Scan for signed integer) SUBROUTINE LX4DEC ( STRING, FIRST, LAST, NCHAR ) AbstractScan a string from a specified starting position for the end of a decimal number. Required_ReadingNone. KeywordsPARSING DeclarationsIMPLICIT NONE CHARACTER*(*) STRING INTEGER FIRST INTEGER LAST INTEGER NCHAR Brief_I/OVARIABLE 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_InputSTRING 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. Detailed_OutputLAST is the last character at or after FIRST such that the substring STRING(FIRST:LAST) is a decimal number. If there is no such substring, LAST will be returned with the value FIRST-1. NCHAR is the number of characters in the decimal number that begins at FIRST and ends at last. If there is no such string NCHAR will be given the value 0. ParametersNone. ExceptionsError free. 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: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. FilesNone. ParticularsThis 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 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 ExamplesSuppose 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 some non-digit character. 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. FIRST = 1 I = 0 DO WHILE ( FIRST .LT. LEN(STRING) ) CALL LX4DEC ( STRING, FIRST, LAST, NCHAR ) IF ( NCHAR .GT. 0 ) THEN I = I + 1 B(I) = FIRST E(I) = LAST FIRST = LAST + 2 ELSE FIRST = FIRST + 1 END IF END DO RestrictionsNone. Literature_ReferencesNone. Author_and_InstitutionJ. Diaz del Rio (ODC Space) W.L. Taber (JPL) VersionSPICELIB Version 1.2.0, 04-AUG-2021 (JDR) Added IMPLICIT NONE statement. Edited the header to comply with NAIF standard. Fixed return value for LAST in $Exceptions section entry #1. SPICELIB Version 1.1.0, 28-NOV-1995 (WLT) Upgraded the routine to handle strings of the form '+.01' and '-.01' which were regarded as non-decimal strings before. SPICELIB Version 1.0.0, 12-JUL-1994 (WLT) |
Fri Dec 31 18:36:33 2021