Hi,
I have a custom class called shpNode, what I want to be able to do is create a number of objects based on this class into an array.
I can create the objects doing it this way;
WITH thisform.Container1
FOR _x = 1 to 10
cName = "shpNode" + ALLTRIM(STR(_x))
.NewObject(cName, "shpNode", "mClass")
cComm = "." + cName + ".Top = 50 + (_x * 10)"
&cComm
cComm = "." + cName + ".Left = 50 + (_x * 10)"
&cComm
cComm = "." + cName + ".Visible = .T."
&cComm
ENDFOR
ENDWITH
This all works fine, but ideally would like to reference the objects as array elements, have tried things like;
ADD OBJECT cName(_x) as shpNode
cName(_x) = .NewObject(cName, "shpNode", "mClass")
Am sure I am close, but can't figure it out and although been using VFP on and off for 20 years have never really used classes before!!!
Thanks
Darren
I have a custom class called shpNode, what I want to be able to do is create a number of objects based on this class into an array.
I can create the objects doing it this way;
WITH thisform.Container1
FOR _x = 1 to 10
cName = "shpNode" + ALLTRIM(STR(_x))
.NewObject(cName, "shpNode", "mClass")
cComm = "." + cName + ".Top = 50 + (_x * 10)"
&cComm
cComm = "." + cName + ".Left = 50 + (_x * 10)"
&cComm
cComm = "." + cName + ".Visible = .T."
&cComm
ENDFOR
ENDWITH
This all works fine, but ideally would like to reference the objects as array elements, have tried things like;
ADD OBJECT cName(_x) as shpNode
cName(_x) = .NewObject(cName, "shpNode", "mClass")
Am sure I am close, but can't figure it out and although been using VFP on and off for 20 years have never really used classes before!!!
Thanks
Darren