#6
Post
by unixkd »
The ChangeValue function can be modified further to be able to deal with fields such as zipcode, telephone etc using a modified version of your DC_NUMINCR() function as shown below:
*
FUNCTION ChangeValue( a, b, oGet)
Local xValue := oGet:getData()
IF ValType(xValue) = "C"
xValue := IF( b[2] > 0, PPS_NUMINCR( xValue ), PPS_NUMINCR( xValue,nil,nil,1 ))
Else
IF( b[2] > 0, xValue ++, xValue -- )
EndIf
oGet:setData(xValue)
RETURN nil
*
*
FUNCTION PPS_numincr ( cVarName, cLoVal, cHiVal, nFlag )
STATIC cVar := ''
LOCAL nVarLength, nNumStart, nNumEnd, nVarPointer, cNewString
DEFAULT nFlag := 0
IF Empty(cVarName)
cVarName := cVar
ENDIF
nVarLength := LEN(cVarName)
nVarPointer := nVarLength
DO WHILE nVarPointer>0
IF SUBSTR(cVarName,nVarPointer,1)>='0' ;
.AND. SUBSTR(cVarName,nVarPointer,1)<='9'
EXIT
ENDIF
nVarPointer--
ENDDO
nNumEnd := nVarPointer
DO WHILE nVarPointer>0
IF (SUBSTR(cVarName,nVarPointer,1)<'0' ;
.OR. SUBSTR(cVarName,nVarPointer,1)>'9') .AND. ;
SUBSTR(cVarName,nVarPointer,1)#' '
EXIT
ENDIF
nVarPointer--
ENDDO
nNumStart := nVarPointer+1
If nFlag == 0
cNewString := STRTRAN(STR(VAL(SUBSTR(cVarName,nNumStart, nNumEnd-nNumStart+1))+1,nNumEnd-nNumStart+1),' ','0')
Else
cNewString := STRTRAN(STR(VAL(SUBSTR(cVarName,nNumStart, nNumEnd-nNumStart+1))-1,nNumEnd-nNumStart+1),' ','0')
EndIf
cVar := SUBSTR(cVarName,1,nNumStart-1)+cNewString+;
SUBSTR(cVarName,nNumEnd+1,nVarLength-nNumEnd)
IF !Empty(cLoVal) .AND. !Empty(cHiVal) .AND. cVar > cHiVal
cVar := cLoVal
ENDIF
RETURN cVar