Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Last Updated User
Message
From
23/02/2005 13:08:32
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
00988451
Message ID:
00989731
Views:
32
>>hi Nadya,
>>
>>The first part does not loop through all the fields. It loops through getfldstate(-1). If a byte indicates a change, then it finds out whether the field really has changed, excluding the user and time fields (you may want to add the insert fields there).
>>
>>It only loops until it finds a field that has changed.
>>
>>A recap,
>>
>>RecordValidation is only called when there is a change or it thinks so
>>
>>We may get a 'false' change, ie repl a field with a value and repl it back with the oldval(). Hence the loop
>>
>>We do not include the User and date fields of both the insert and update
>>
>>If you a shorter way I have overlooked, plse let me know
>>
>>
>>cheers
>
>
>FUNCTION UpdateUserAndTime()
>*  Function..........: UpdateUserAndTime
>*  Author............: Gregory Adam / Nadya Nosonovsky
>*  Project...........: Visual Collections
>*  Created...........: 02/02/2005  15:17:53
>*  Copyright.........: (c) Jzanus, LTD, 2005
>*  Major change list.:
>
>LOCAL lcFieldState, lnPos, lnOccurance
>
>lcFieldState = SUBSTR(GETFLDSTATE(-1),2) && The first character returns deletion status
>lnOccurance = 1
>lnPos = AT('2', m.lcFieldState, m.lnOccurance)
>DO WHILE m.lnPos > 0
>    DO CASE
>	CASE !FieldChanged(FIELD(m.lnPos))
>&& not changed
>
>	CASE INLIST(FIELD(m.lnPos), "cLast_Updated_User", "tLast_Updated_Date")
>&& ignore
>
>	OTHERWISE
>		REPLACE cLast_Updated_User WITH getuserid(), tLast_Updated_Date WITH DATETIME()
>		lnPos = 0
>	ENDCASE
>	IF m.lnPos > 0
>	   lnOccurance = m.lnOccurance + 1
>	   lnPos = lnPos = AT('2', m.lcFieldState, m.lnOccurance)
>	ENDIF	
>ENDDO
>
>ENDFUNC
>*--------------------------------------------------------------------------
>FUNCTION FieldChanged(tcFieldName)
>
>LOCAL llReturn
>
>DO CASE
>CASE ISNULL(OLDVAL(m.tcFieldName)) OR ISNULL(EVALUATE(m.tcFieldName))
>	llReturn = (ISNULL(OLDVAL(m.tcFieldName)) <> ISNULL(EVALUATE(m.tcFieldName)) )
>OTHERWISE
>	llReturn = (OLDVAL(m.tcFieldName) <> EVALUATE(m.tcFieldName))
>ENDCASE
>
>RETURN m.llReturn
>
>ENDFUNC
>
Ok,

two remarks

(1) Yes, that one is shorter. I take it that you handle the INSERT in another part of the code, although it can easily be added here

(2) Field(n) returns upper, watch the collating sequence
CASE INLIST(FIELD(m.lnPos), "cLast_Updated_User", "tLast_Updated_Date")
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform