*!* 函数说明
*!* toLeftStr(tcSearched, tcSearchFor)toLeftStr(tcSearched, tcSearchFor) 获取字符串tcSearched的前面部分,以tcSearchFor分割!tcSearchFor。
*!* toRightStr(tcSearched, tcSearchFor) 获取字符串tcSearched的后面部分,以tcSearchFor分割!不包含tcSearchFor。
*!* toLimitStr(tcSearched, tLimit, tnCount) 获取tcSearched串中以tcLimit为分隔符分割后第tnCount段的数据。
*!* toTrimStr(tcText, tlSpace) 删除前后空格和空行
*!* toMidStr(tcSearched, tcBegin, tcEnd) 根据tcSearched返回tcBegin和tcEnd之间的字符串,如果没有匹配的内容,返回空!
****************************************
* 功能说明:
* 根据tcSearched返回tcBegin和tcEnd之间的字符串,如果没有匹配的内容,返回空!
*
* 参数说明:
* tcSearched 查找字符串
* tcBegin 开始字符串
* tcEnd 结束字符串
*
* 返回说明: 字符串内容
*
* 日 期: 2001.08.27
* 作 者: 天涯闲人
*
* 修改记录:
****************************************
FUNCTION toMidStr
Lparameters tcText, tcBegin, tcEnd
Local lcHead, lcReturn
lcHead = toLeftStr(tcText, tcEnd)
if Empty(lcHead)
return ''
endif
lcReturn = toRightStr(lcHead, tcBegin)
return lcReturn
ENDFUNC
****************************************
* 功能说明:
* 获取tcSearched串中以tcLimit为分隔符分割后第tnCount段的数据。
*
* 参数说明:
* tcSearched 查找的字符串
* tcLimit 分隔字符串
* tcTime 第几次内容
*
* 返回说明: 字符串内容
*
* 日 期: 2001.08.27
* 作 者: 天涯闲人
*
* 修改记录:
****************************************
FUNCTION toLimitStr
LPARAMETERS tcString, tcLimit, tnTime
PRIVATE ALL LIKE l*
lcReturn = ''
lcString = tcString + tcLimit
IF tnTime = 1
lnAt = AT(tcLimit, lcString, tnTime)
lcReturn = SUBSTR(lcString, 1, lnAt - 1)
RETURN lcReturn
ENDIF
lnAt = AT(tcLimit, lcString, tnTime)
IF lnAt <= 0
RETURN lcReturn &&返回空串
ENDIF
lnAt_1 = AT(tcLimit, lcString, tnTime - 1)
lcReturn = SUBSTR(lcString, lnAt_1 + LEN(tcLimit), lnAt - lnAt_1 - LEN(tcLimit))
RETURN lcReturn
ENDFUNC
****************************************
* 功能说明:
* 删除前后空格和空行
*
* 参数说明:
* tcText 需要处理的字符串
*
* 返回说明: 删除空格和空行
*
* 日 期: 2001.08.27
* 作 者: 天涯闲人
*
* 修改记录:
****************************************
FUNCTION toTrimStr
LPARAMETERS tcText, tlSpace
Local lcRet, lcReturn, lcText, lnFind, lcLine
lcText = tcText
lcRet = CHR(13) + CHR(10)
lcReturn = ''
if ((chr(13)$lcText) and !(chr(10)$lcText))
lcText = strtran(lcText, chr(13), chr(13) + chr(10))
endif
lcText = strtran(lcText, chr(9), space(4))
lnFind = AT(lcRet , lcText, 1)
DO WHILE lnFind > 0
lcLine = toLeftStr(lcText, lcRet)
if tlSpace
lcLine = alltrim(lcLine)
endif
if !Empty(lcLine)
lcReturn = lcReturn + lcLine + lcRet
endif
lcText = toRightStr(lcText, lcRet)
lnFind = AT(lcRet , lcText, 1)
ENDDO
lcReturn = lcReturn + lcText
RETURN lcReturn
ENDFUNC
****************************************
* 功能说明:
* 获取字符串tcSearched的前面部分,以tcSearchFor分割!tcSearchFor。
*
* 参数说明:
* tcSearched 被查找的字符串
* tcSearchFor 查找的字符串
*
* 返回说明: 前面部分内容
*
* 日 期: 2001.08.27
* 作 者: 天涯闲人
*
* 修改记录:
****************************************
function toLeftStr
lparameters tcSearched, tcSearchFor
Local lcReturn, lnAt
if len(tcSearchFor) = 0
return ''
endif
lnAt = AT(tcSearchFor, tcSearched, 1)
if lnAt <= 1 &&没有匹配
return ''
endif
lcReturn = left(tcSearched, lnAt - 1)
return lcReturn
endfunc
****************************************
* 功能说明:
* 获取字符串tcSearched的后面部分,以tcSearchFor分割!不包含tcSearchFor。
*
* 参数说明:
* tcSearched 字符串内容
* tcSearchFor 查找串内容
*
* 返回说明: 字符串
*
* 日 期: 2001.08.27
* 作 者: 天涯闲人
*
* 修改记录:
****************************************
function toRightStr
lparameters tcText, lcFind
Local lcReturn , lnAt
if len(lcFind) = 0
return ''
endif
lnAt = AT(lcFind, tcText, 1)
if lnAt <= 0 &&没有匹配
return ''
endif
lcReturn = right(tcText, len(tcText) - lnAt - len(lcFind) + 1)
return lcReturn
endfunc