Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Examine Changes
Message
 
 
To
19/08/2009 11:54:38
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01418972
Message ID:
01419007
Views:
55
I actually found something - I knew it was there

message #1081688

(had to correct the typos in the code first).

>>>>>Hi everybody,
>>>>>
>>>>>Does someone has a code snippet ready to get all changed fields from GetFldState + what the difference is (original value / new value). Just looking for already written code, I guess.
>>>>>
>>>>>Thanks.
>>>>
>>>>UT Magazine, May 2003, A Basic Audit Trail
>>>
>>>The snippet that loops through actual changes (for the "update" case, as opposed to new records or deleted records) is this one:
>>>
>>>
>>>lcChanges = ""
>>>  for lnField = 1 to fcount()
>>>    lcFieldName = field(lnField)
>>>    lcChanges = lcChanges + lcFieldName + ": ";
>>>      + transform(oldval(lcFieldName)) + " -> ";
>>>      + transform(eval(lcFieldName));
>>>      + chr(13) + chr(10)
>>>  next
>>>
>>>
>>>Come to think of it, this one seems to be missing instructions to compare whether there was an actual change in each specific field.
>>
>>Yes, exactly. In my case the missing piece is to only examine GetFldState 2 or 4. Thus I said I'm taking this piece as a basis for a new method which I want to invoke as a developer's tool. I'm just not exactly sure, how would I invoke this on Demand. The method that checks for changes is in the base VPM class and I want to fire the method I need only in particular instance for debugging purposes (I'm getting "Information saved" message when I'm only viewing the info).
>
>inlist(GetFldState(...), 2, 4) is not an absolute guarantee that the data changed. The user might press a key in a TextBox, then change his mind and press backspace - Visual FoxPro will still mark the field as "touched". Just add a condition to the above code, whether oldval(lcFieldName) is, indeed, different from eval(lcFieldName).
>
>As to invoking the code conditionally... Well, you can place the code anywhere you like, and invoke it if a certain condition is true. Using this for an audit trail was just for my particular needs. You should seriously consider having an audit trail, but you can invoke this code from a button press, or in a Form.SaveRecord() method and only if a certain variable is true. I suggest moving the code (an adapted version, most likely) to some function in your procedure library, so that it is easily accesible from different places.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform