Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Year 0000
Message
De
15/04/2005 12:37:26
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01003937
Message ID:
01005188
Vues:
29
>>>Unrelated question, Fabio.
>>>Do you know the simplest way to find out all changed fields using GetFldState result without using AT function?
>>>
>>>Here is a code where I'm using in a similar method. I'm wondering, if this code could be simplified:
>>>
>>>
>>>	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(UPPER(FIELD(m.lnPos)), UPPER("cLast_Updated_User"), ;
>>>				UPPER("tLast_Updated_Date"))
>>>
>>>&& ignore
>>>		OTHERWISE
>>>			REPLACE cLast_Updated_User WITH ;
>>>				IIF(VARTYPE(m.gcUserID) == "C", m.gcUseriID, getuserid()), ;
>>>				tLast_Updated_Date WITH DATETIME()
>>>			lnPos = 0
>>>		ENDCASE
>>>		IF m.lnPos > 0
>>>			lnOccurance = m.lnOccurance + 1
>>>			lnPos = AT('2', m.lcFieldState, m.lnOccurance)
>>>		ENDIF
>>>	ENDDO
>>>
>>
>>What is FieldChanged(FIELD(m.lnPos)) ?
>>
>>I look you want do this if a field is updated:
>>
>>REPLACE cLast_Updated_User WITH ;
>>	IIF(VARTYPE(m.gcUserID) == "C", m.gcUseriID, getuserid()), ;
>>	tLast_Updated_Date WITH DATETIME()
>>
>
>FieldChanged is a separate function. My question is how can I simplify the above logic and how can I avoid repeating this logic in the trigger...

Nadya, without known what do FieldChanged() is impossible simplify the logic;
I can simplify the syntax, but the logic still the same:
STORE GETFLDSTATE(-1)	TO row_State
FOR iField=RAT('2',m.row_State)-1 TO 1 STEP -1
   IF FieldChanged(FIELD(m.lnPos)) ;
     AND !INLIST(UPPER(FIELD(m.lnPos)), UPPER("cLast_Updated_User"), ; && remove upper, VFP is not C !
				UPPER("tLast_Updated_Date"))
       REPLACE cLast_Updated_User WITH ;
         IIF(VARTYPE(m.gcUserID) == "C", m.gcUseriID, getuserid()), ;
              tLast_Updated_Date WITH DATETIME()
       EXIT
   ENDIF
   STORE RAT('2',LEFT(m.row_State,m.iField))	TO iField
NEXT
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform