*!*
A1 = '-.1232'
&& -0.12
*!*
A1 = '-.123-2' && 0
*!*
A1 = '.1.232'
&& 0
*!*
A1 = '123A2'
&& 0
A1 = '1232'
?NumStr(A1)
FUNCTION NumStr(cStr)
IF SUBSTR(cStr,1,1) = "-" && 第一个"-"
IF RAT('-',cStr) # 1
&& 有多个"-"
RETURN 0
ELSE
IF AT(".",cStr) # RAT(".",cStr)
&& 有多个"."
RETURN 0
ELSE
IF EMPTY(CHRTRAN(cStr, "-.012345789", ""))
RETURN TRANSFORM(VAL(cStr))
ELSE
RETURN 0
ENDIF
ENDIF
ENDIF
ELSE
IF AT(".",cStr) # RAT(".",cStr)
&& 有多个"."
RETURN 0
ELSE
IF EMPTY(CHRTRAN(cStr, ".012345789", ""))
RETURN TRANSFORM(VAL(cStr))
ELSE
RETURN 0
ENDIF
ENDIF
ENDIF
ENDFUNC