FIX: SETALL() Corrupts Properties of Custom Objects (183296)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 3.0
- Microsoft Visual FoxPro for Windows 3.0b
- Microsoft Visual FoxPro for Windows 5.0
- Microsoft Visual FoxPro for Windows 5.0a
This article was previously published under Q183296 SYMPTOMS
When the SETALL() method is used to set a text property of custom objects,
subsequent use of the SETALL() method corrupts the property for all but the
first object.
RESOLUTION
Create a procedure to set the properties of the objects in the container as
shown in the SetAllProp procedure below. Use this procedure in place of the
SETALL() method for setting the properties of custom objects.
Sample Code
*-- Code begins here.
CLEAR
oX = CREATEOBJECT("Container")
FOR counter = 1 TO 30
oX.ADDOBJECT("x"+LTRIM(STR(counter)), "Example")
ENDFOR
=SetAllProp("MyProperty", "", "oX")
=SetAllProp("MyProperty", "Example One - Test", "oX")
? oX.CONTROLS[1].MyProperty
? oX.CONTROLS[2].MyProperty
? oX.CONTROLS[3].MyProperty
? oX.CONTROLS[30].MyProperty
? && Separator
? && Separator
*-- PROCEDURE SetAllProp
*-- Step through the objects in a container and set the passed property
*-- for each object.
*-- Parameters: lcProperty - The property to change.
*-- lcValue - The property's value.
*-- lcContainer - The container containing the objects whose
*-- properties are to be changed.
PROCEDURE SetAllProp()
PARAMETERS lcProperty, lcValue, lcContainer
*-- Load the object names into an array.
=AMEMBERS(laObjects, EVALUATE(lcContainer), 2)
*-- Step through the array and change the passed property for each
*-- object.
FOR liCounter = 1 TO ALEN(laObjects)
lcCommand = lcContainer + "." + laObjects(liCounter) + "." + ;
lcProperty + "=" + "'" + lcValue + "'"
&lcCommand
ENDFOR
ENDPROC
DEFINE CLASS Example AS CUSTOM
MyProperty = "Initial MyProperty"
ENDDEFINE
*-- Code ends here.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. This has been corrected in Visual FoxPro
6.0.
Modification Type: | Major | Last Reviewed: | 5/10/2003 |
---|
Keywords: | kbBug kbcode kbfix KB183296 |
---|
|