Whenever you need to to handle comma-separated string, you might want to check the function below, which makes use of VFP's ALINES() function to return a certain value in the string.
* Parameters: String (character) , which part (numeric), delimiter (character)
PARAMETERS cCsv, nPart, pdelimiter
IF PCOUNT() < 3
pDelimiter = ","
ENDIF
cCsv = STRTRAN(cCsv, pDelimiter, " "+CHR(13) )
ALINES(aCsv, cCsv , .T.)
* When array element 1 = .False. => return ""
* When the number of array elements < nPart => return ""
* Otherwise, return the piece of the string
RETURN IIF( TYPE( "aCsv[1]" ) = "L" , "", IIF( ALEN(aCsv,1) < nPart , "", aCsv[nPart] ) )
Aug 1, 2008
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2008
(3)
- ▼ August 2008 (2)
-
►
2006
(6)
- ► October 2006 (1)
- ► September 2006 (2)
No comments:
Post a Comment