home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / clipper / asciisum.c < prev    next >
C/C++ Source or Header  |  1993-10-14  |  1KB  |  61 lines

  1. /*
  2.  * GT CLIPPER STANDARD HEADER
  3.  *
  4.  * File......: asciisum.c
  5.  * Author....: Andy M Leighton
  6.  * BBS.......: The Dark Knight Returns
  7.  * Net/Node..: 050/069
  8.  * User Name.: Andy Leighton
  9.  * Date......: $Date$
  10.  * Revision..: $Revision$
  11.  *
  12.  * This is an original work by Andy Leighton and is placed in the
  13.  * public domain.
  14.  *
  15.  * Modification history:
  16.  * ---------------------
  17.  *
  18.  * $Log$
  19.  *
  20.  */
  21.  
  22. /*
  23.  *  $DOC$
  24.  *  $FUNCNAME$
  25.  *      GT_ASCIISUM()
  26.  *  $CATEGORY$
  27.  *      String
  28.  *  $ONELINER$
  29.  *      Sum the ascii values in a string.
  30.  *  $SYNTAX$
  31.  *      GT_AsciiSum(<cStr>) --> nSum
  32.  *  $ARGUMENTS$
  33.  *      <cStr>  - The string to sum
  34.  *  $RETURNS$
  35.  *      nSum    - The sum of all ascii values in <cStr>.
  36.  *  $DESCRIPTION$
  37.  *      Sum the ascii value of every character in the passed string
  38.  *      and return the result.
  39.  *  $EXAMPLES$
  40.  *  $END$
  41.  */
  42.  
  43. #include "extend.h"
  44.  
  45. CLIPPER
  46. GT_asciisum()
  47. {
  48.     char *str;
  49.    int  len, i;
  50.     long ascSum = 0;
  51.  
  52.     str = _parc(1);
  53.    len = _parclen(1);
  54.  
  55.    for (i = 0; i <= len; i++,str++) {
  56.       ascSum += *str;
  57.     }
  58.  
  59.    _retnl(ascSum);
  60. }
  61.