home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / CHAP20.EXE / CHP2004.PRG < prev    next >
Encoding:
Text File  |  1991-04-30  |  738 b   |  29 lines

  1. /*
  2.    Listing 20.4  PARSE()
  3.    Author: Joe Booth
  4.    Excerpted from "Clipper 5: A Developer's Guide"
  5.    Copyright (c) 1991 M&T Books
  6.                       501 Galveston Drive
  7.                       Redwood City, CA 94063-4728
  8.                       (415) 366-3600
  9. */
  10.  
  11. //───── NOTE: must compile with the /N option!
  12.  
  13. function PARSE( pstring,pdelim )
  14. STATIC def_delim := ","       // default delimiter
  15. LOCAL rlist :={},k
  16. pdelim := if(pdelim==NIL, def_delim, pdelim)
  17. while len(pstring) > 0
  18.     if (k := at(pdelim,pstring) ) > 0
  19.        Aadd(rlist,left(pstring,k-1))
  20.        pstring := substr(pstring,k+1)
  21.     else
  22.        Aadd(rlist,pstring)
  23.        pstring :=""
  24.     endif
  25. enddo
  26. return rlist
  27.  
  28. // end of file CHP2004.PRG
  29.