home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / CLIPB52.ZIP / SPENCE.ZIP / RICKP.PRG < prev   
Encoding:
Text File  |  1990-06-04  |  1.1 KB  |  46 lines

  1.     * The source code provided herein remains the property of Rick
  2.     * Spence and Software Design Consultants. You are, however, free to
  3.     * use it, but please do not republish.
  4.  
  5.  
  6.     * RICKP.PRG
  7.     *
  8.     * Rick Spence's Clipper Code fropm the Advanced C presentation,
  9.     * 1990 Devcon
  10.  
  11.     * Program 9 - 6  Tokenizing Functions
  12.  
  13.     #define VOID .T.
  14.  
  15.     STATIC _token_string, _separators
  16.  
  17.     FUNCTION tok_start(tok_str, seps)
  18.  
  19.         _token_string = tok_str
  20.         _separators = seps
  21.  
  22.     RETURN VOID
  23.  
  24.  
  25.     FUNCTION next_tok(token)
  26.  
  27.     LOCAL where_sep, ret_val
  28.  
  29.         ret_val = .F.
  30.         IF !(_token_string == "")
  31.             where_sep = cstrcspn(_token_string, _separators)
  32.             DO WHILE where_sep = 1
  33.                 _token_string = substr(_token_string, 2)
  34.                 where_sep = cstrcspn(_token_string, _separators)
  35.             ENDDO
  36.  
  37.             IF where_sep > 1
  38.                 token = substr(_token_string, 1, where_sep - 1)
  39.                 _token_string = substr(_token_string, where_sep + 1)
  40.                 ret_val = .T.
  41.             ENDIF
  42.         ENDIF
  43.  
  44.     RETURN ret_val
  45.  
  46.