Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Because FOR EACH fail into the Collection class
Message
From
27/04/2004 07:06:35
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Because FOR EACH fail into the Collection class
Miscellaneous
Thread ID:
00898430
Message ID:
00898430
Views:
72
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
Next
Reply
Map
View

Click here to load this message in the networking platform