Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Because FOR EACH fail into the Collection class
Message
De
27/04/2004 07:06:35
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Because FOR EACH fail into the Collection class
Divers
Thread ID:
00898430
Message ID:
00898430
Vues:
71
When you use a FOR EACH into a Collection Class for a objects collection,
you can yourselves be found in a sea of problems.
This why VFP does not return the reference to the object,
but it creates a references alias on the fly,
and this reference change for every FOR EACH you use.
CLEAR 
oEmpty = CREATEOBJECT('empty')

oCollect = CREATEOBJECT('collection')

oCollect.Add(m.oEmpty)

? "For Each collection"
FOR EACH oElement IN oCollect
	? "A EACH oElement Is the same reference ?", m.oElement = m.oEmpty  && oElement is not the oEmpty object
	FOR EACH oElementAnother IN oCollect
		? "A EACH oElement Is repeatable ?",m.oElementAnother = m.oEmpty  	&& oElementAnother is not the oEmpty object	
		? "A EACH oElement Is the same reference ?"	,m.oElementAnother = m.oElement 									&& oElementAnother is not the oElement object
	ENDFOR
ENDFOR

? "For index collection"
FOR k=1 TO m.oCollect.Count
  ? "oCollect[m.k]      Is the same reference ?",oCollect[m.k]      = m.oEmpty   && standard FOR return the true object reference
  ? "oCollect.Item[m.k] Is the same reference ?",oCollect.Item[m.k] = m.oEmpty
ENDFOR

ADDPROPERTY(oCollect,"objRef[1]",.NULL.)
oCollect.objRef[1]=m.oEmpty

? "For each and index on a property array of objects"
FOR EACH oElement IN oCollect.objRef
  ? "oElement      Is the same reference ?",oElement = m.oEmpty   && standard FOR return the true object reference
  ? "oCollect.objRef[1] Is the same reference ?",oCollect.objRef[1] = m.oEmpty
	* repeatable it is evident
ENDFOR
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform