Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
The most elegant and readable way (and efficient)
Message
De
11/12/2005 12:50:57
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01076714
Message ID:
01076978
Vues:
20
>Here is what I wrote yesterday but haven't time to test. Now I'm going to work on this form. As you see, it's the same as Sergey proposed and the easiest solution here:
>
>
>LOCAL lcOldPK, lcNewPk, lnI
>
>LOCAL ARRAY laOldRecord[1], laNewRecord[1]
>
>lcOldPk = ALLTRIM(this.Parent.cboCarriers.value)
>lcNewPk = ALLTRIM(this.Parent.cboCarrierToMerge.Value)
>
>LOCATE FOR cCarriers_pk = m.lcOldPk
>SCATTER FIELDS EXCEPT CCARRIERS_PK, CCARRIER_NAME, IACTIVE_FLAG, TENTERED_DATE, CENTERED_USER, TLAST_UPDATED_DATE, ;
>					  CLAST_UPDATED_USER, CUSER_DEF1, CUSER_DEF2, CUSER_DEF3, CUSER_DEF4 TO laOldRecord
>
>replace iActive_flag WITH 0
>
>LOCATE FOR cCarriers_pk = m.lcNewPk
>SCATTER FIELDS EXCEPT CCARRIERS_PK, CCARRIER_NAME, IACTIVE_FLAG, TENTERED_DATE, CENTERED_USER, TLAST_UPDATED_DATE, CLAST_UPDATED_USER, CUSER_DEF1, CUSER_DEF2, CUSER_DEF3, CUSER_DEF4 TO laNewRecord
>
>for lnI =1 to ALEN(laOldRecord)
>    IF NOT EMPTY(laOldRecord[m.lnI]) AND EMPTY(laNewRecord[m.lnI])
>       laNewRecord[m.lni] = laOldRecord[m.lnI]
>    endif
>NEXT
>
>GATHER FROM laNewRecord FIELDS EXCEPT  ;
>					CCARRIERS_PK, CCARRIER_NAME, IACTIVE_FLAG, TENTERED_DATE, CENTERED_USER, TLAST_UPDATED_DATE, ;
>					CLAST_UPDATED_USER, CUSER_DEF1, CUSER_DEF2, CUSER_DEF3, CUSER_DEF4
>
>

This is another way:
LOCAL lnI, OldRecord,aFields

=LOOKUP(cCarriers_pk,ALLTRIM(this.Parent.cboCarriers.value) ,cCarriers_pk)

SCATTER FIELDS EXCEPT CCARRIERS_PK, CCARRIER_NAME, IACTIVE_FLAG, TENTERED_DATE, CENTERED_USER, TLAST_UPDATED_DATE, ;
					  CLAST_UPDATED_USER, CUSER_DEF1, CUSER_DEF2, CUSER_DEF3, CUSER_DEF4 NAME OldRecord

replace iActive_flag WITH 0

=LOOKUP(cCarriers_pk,ALLTRIM(this.Parent.cboCarrierToMerge.Value),cCarriers_pk)

FOR lnI =1 TO AMEMBERS(aFields,m.OldRecord)
	IF EMPTY(EVALUATE(aFields[m.lnI]))
		REPLACE (aFields[m.lnI]) WITH GETPEM(m.OldRecord,aFields[m.lnI])
	ENDIF
ENDIF
or
FOR lnI =1 TO AMEMBERS(aFields,m.OldRecord)
	IF EMPTY(EVALUATE(aFields[m.lnI]))
           LOOP
	ENDIF
        REMOVEPROPERTY(m.OldRecord,aFields[m.lnI])
NEXT
GATHER NAME OldRecord
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform