Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
When the record was really changed?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01035985
Message ID:
01036097
Views:
10
I have a function in our database IsFieldChanged using code from Gregory Adam. BTW, your code will fail in case of NULL in one of the field.

I like the checksum idea better. But it looks like it can work with one record only. If we're using buffering mode 5 (we're using it in 65% of cases), the Checksum would not work.

Still, the main problem is: how can we incorporate this idea into the framework? Do we really have to? Or we better will live with the current behavior. The possibility of the user trying to type something, then changing his/her mind is not that big.

>Building on Hilmar's idea... why not use a function and check either oldval or curval (depending on your needs). Here's an example function that you can use, just send in the alias. It loops through all the fields in the table and compares their values and return .T. or .F. depending on whether the record is dirty.
>
>
?TableIsDirty("MyTable")
>
>*************************
>FUNCTION TableIsDirty(tcAlias)
>*************************
>   LOCAL llReturn, lcFieldName, lnCount
>   llReturn = .F.
>   IF USED("tcAlias")
>      FOR lnCount = 1 TO FCOUNT(tcAlias)  && Loop for number of fields
>        lcFieldName = tcAlias + "." + FIELD(lnCount, tcAlias, 0)  && Display each field
>        IF !(EVALUATE(lcFieldName) == OLDVAL(lcFieldName)) && or CURVAL() depending on your needs
>           llReturn = .T.
>           EXIT && we've found at least one dirty field
>        ENDIF
>      ENDFOR
>   ENDIF
>   RETURN llReturn
>ENDFUNC
>
>
>>>>Hi everybody,
>>>>
>>>>I raised this problem once already, but would like to discuss it again.
>>>>
>>>>If the user changed someting in the form, but then changed his/her mind and removed the change, the GetFldState function would anyway report this record as changed. How do you solve this problem in your applications? Are you triggering all the logic, which is triggered when the user really changed something? Or you're not using GetFldState function (GetNextModified)?
>>>>
>>>>In our case we're using the framework. So, if we want to implement different way of detecting the change, it would be a complicated task.
>>>>
>>>>Thanks in advance.
>>>
>>>I am not sure whether it is worthwhile, but it ain't too difficult either. You can compare each field with its previous value (before the user started editing) with the oldval() function.
>>>
>>>
>>>if field1 = oldval("Field1")
>>>  * No change in this field
>>>endif
>>>
>>
>>My idea was to save the record with scatter name oPrevStateRecord and then compare with the current record. But since we're in the framework environment, the task is not that trivial...
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform