home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / pcmag / vol12n05.zip / NXTKEY.PRG < prev    next >
Text File  |  1992-09-14  |  2KB  |  37 lines

  1. *********************************************************************
  2. *  FUNCTION NxtKeyCod                                     Clipper 5
  3. *  Increments a key code of serial number that is made up of
  4. *  letters and numerals.
  5. *
  6. *  - The characters used in the code are from 0 - 9 and then A - Z
  7. *    in ascending order.
  8. *  - The previous key code passed to this procedure should have the
  9. *    maximum length allowed so that the system can check whether
  10. *    the next key code will exceed the limit.
  11. *    If so, it returns all "*".
  12. *  - Spaces are treated as "0".  Trailing spaces are significant and
  13. *    replaced by "0", while leading spaces will remain unchanged
  14. *********************************************************************
  15. FUNCTION NxtKeyCod( ckeycode )
  16. LOCAL cchrbank, nkeylen, nct, cwkchr, nwkchrseq
  17. cchrbank = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  18. nkeylen = LEN( ckeycode)
  19. ckeycode = SUBSTR( TRIM( ckeycode ) + ;
  20.   REPLICATE( "0", nkeylen), 1, nkeylen)
  21. FOR nct = 1 TO nkeylen
  22.    cwkchr     = SUBSTR( ckeycode, -1 *nct, 1 )
  23.    cwkchr     = IIF( cwkchr = " ", "0", cwkchr )
  24.    nwkchrseq  = AT( cwkchr, cchrbank )
  25.    nwkchrseq  = nwkchrseq + 1
  26.    nwkchrseq  = IIF( nwkchrseq > LEN( cchrbank), 1, nwkchrseq )
  27.    cwkchr     = SUBSTR( cchrbank, nwkchrseq, 1 )
  28.    ckeycode   = SUBSTR( ckeycode, 1, nkeylen - nct) + cwkchr +;
  29.       SUBSTR( ckeycode, nkeylen -nct +2)
  30.    IF nwkchrseq != 1
  31.       EXIT
  32.    ELSEIF nct = nkeylen
  33.       ckeycode = REPLICATE( "*", nkeylen )
  34.    ENDIF
  35. NEXT
  36. RETURN ckeycode
  37.