Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Comparing to NULL
Message
From
24/07/2007 06:55:12
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01243011
Message ID:
01243101
Views:
36
Yes, I know this function. What I was asking is how to compare current value with old value. This is the segment of code I was using:
lcType = TYPE( FIELD( i ) )
!( NVL( EVALUATE(FIELD(i)), Str2Exp( '' ) ) == NVL( OLDVAL(FIELD(i), "V_MYTABLE"), Str2Exp( '' ) ) )
Here is Str2Exp:
*-- Passed a string and a data type, return the expression after conversion to the specified data type
FUNCTION Str2Exp( tcExp, tcType )
  *** Convert the passed string to the passed data type
  LOCAL luRetVal, lcType

  *** Remove double quotes (if any) 
  tcExp = STRTRAN( ALLTRIM( tcExp ), CHR( 34 ), "" ) 
  *** If no type passed -- display error message
  *** the FUNCTION is not clairvoyant
  IF TYPE( 'tcType' ) = 'C'
    lcType = UPPER( ALLTRIM( tcType ) )
  ELSE
    *** Type is a required parameter. Let the developer know
    ERROR 'Missing Parameter: Expression type is a required parameter to Str2Exp'
  ENDIF
  *** Convert from Character to type
  DO CASE
    CASE INLIST( lcType, 'I', 'N' ) AND INT( VAL( tcExp ) ) == VAL( tcExp ) && Integer
      luRetVal = INT( VAL( tcExp ) )
    CASE INLIST( lcType, 'N', 'Y')                      && Numeric or Currency
      luRetVal = VAL( tcExp )
    CASE INLIST( lcType, 'C', 'M' )                     && Character or memo
      luRetVal = tcExp
    CASE lcType = 'L'                                   && Logical
      luRetVal = IIF( NOT EMPTY( tcExp ), .T., .F. )
    CASE lcType = 'D'                                   && Date 
      luRetVal = CTOD( tcExp )
    CASE lcType = 'T'                                   && DateTime 
      luRetVal = CTOT( tcExp )
    OTHERWISE
      *** There is no otherwise unless, of course, Visual FoxPro adds
      *** a new data type. In this case, the function must be modified 
  ENDCASE
  *** Return value as Data Type
  RETURN luRetVal
ENDFUNC
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform