home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / clipper / strasint.c < prev    next >
Text File  |  1993-05-24  |  983b  |  26 lines

  1. /*****************************************************************************
  2. * Function: _GT_Internal_StringAsInt()                                       *
  3. * Syntax..: int _GT_Internal_StringAsInt(char *String, int Start, int End)   *
  4. * Usage...: Convert a numeric value in a string to an int value.             *
  5. * By......: David A Pearson                                                  *
  6. *****************************************************************************/
  7.  
  8. #define ISDIGIT(c)      ((c) >= '0' && (c) <= '9')
  9.  
  10. int _GT_Internal_StringAsInt(char *String, int Start, int End)
  11. {
  12.         int  Decimal = 1;
  13.         int  Digit   = End;
  14.         int  Value   = 0;
  15.  
  16.         for (Digit = End; Digit >= Start; Digit--)
  17.         {
  18.                 if (ISDIGIT(String[Digit]))
  19.                 {
  20.                         Value   += (String[Digit] - 0x30) * Decimal;
  21.                         Decimal *= 0xA;
  22.                 }
  23.         }
  24.         return(Value);
  25. }
  26.