Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problems with class inherritence
Message
From
04/05/2000 10:15:32
Marco Beuk
Innovero Software Solutions
The Hague, Netherlands
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Problems with class inherritence
Miscellaneous
Thread ID:
00366082
Message ID:
00366082
Views:
49
(See the end for the WebCollection_ Class)

Here is the problem:

I have a WebTable_ class with a WebCollection_ class stored in a propertie and also a _GetOutput method.
In this WebCollection class i add WebRow_ classes.

The WebRow_ class also has a WebCollection_ class stored in a propertie and has a _GetOutput method.
In this WebCollection class i add WebCell_ classes.

( In each class WebCollection_ class is stored with
CREATEOBJECT( 'WebCollection_' ) )


Example: i have 1 table with 3 rows and each row has 3 cells.

When i call the WebTable_:_GetOutput() this method builds a string and calls the WebCollection_:_GetOutput(). This method loops through the object array and calls for each WebRow_ class the WebRow_:_GetOutput(). This method builds a string and calls the WebCollection_:_GetOutput(). The method loops through the object array and calls for each WebCell_ class the WebCell_:_GetOutput().
This method builds a string and returns.

Finally i should get a full string containing a HTML Table with 3 rows and each row 3 cells.
But it's going wrong in the WebCollection_:_GetOutput method.

What i get is a table with 3 rows, the first row has 3 cells. But the next rows ( as many as you like ) have each 1 cell ( the last WebCell_ in the WebCollection class ).
When i call the _GetOutput method for each WebRow_ class in the WebCollection class of the WebTable seperate, it get the right string back.

When i subclass the WebCollection_ class twice and copy and paste the _GetOutput method from the WebCollection into these subclasses and than i use for the WebTable_ and the WebRow_ classes these different subclasses i get the right string.

am I doing something wrong? I can't see it.
I think when i use the WebCollection class multiple times in the same tree structure fox does something wrong with the object array-properties.

Does somebody know this 'problem' or know what to do?


***********************************************
Class WebCollection (based on the Custom class)
***********************************************
array-propertie: _objects[ ]
methods: _AddObject() and _GetOutput()

*****************************
WebCollection:_AddObject
*****************************
LPARAMETERS cpClassName, opObject

WITH This
IF NOT EMPTY( cpClassName ) OR TYPE( 'opObject' ) = 'O'
._ActiveObject = NULL

._ObjectCount = ._ObjectCount + 1
DIMENSION ._Objects[ ._ObjectCount ]
._Objects[ ._ObjectCount ] = IIF( TYPE( 'opObject' ) #;
'O', CREATEOBJECT( cpClassName ), opObject )

._ActiveObject = ._Objects[ ._ObjectCount ]
ENDIF
ENDWITH

RETURN ( This._ActiveObject )

*******************************
WebCollection:_GetOutput
*******************************
LOCAL cOutput, oObject
cOutput = ''

WITH This
IF ._ObjectCount > 0
._ActiveObject = NULL

FOR EACH oObject IN ._Objects
IF TYPE( 'oObject' ) = 'O'
cOutput = cOutput + oObject._GetOutput()
ENDIF
ENDFOR
._ActiveObject = ._Objects[ 1 ]
ENDIF
ENDWITH

RETURN ( cOutput )


Thanks for reading.
Next
Reply
Map
View

Click here to load this message in the networking platform