Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
PARENT is not an Object
Message
 
 
To
11/01/1999 12:42:15
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00174673
Message ID:
00174760
Views:
28
George,

>btw, can I automatically include you text as quotes :-)

I see Garrett told you how to get it automatically.

>The relationship is that 2 is part of 1. I am setting up a series of objects to create HTML Tables (mostly as an OO Programming exercise). So my Table is an object, each row is an object & each Cell is an object.

First you might be doing a little overkill on creating HTML tables. If you have VFP6 there is a class already that'll do it. Here's a snippet of code that does the job pretty well:
\<table border=1 cellpadding=2>
n = afields( laJunk )
scan
   scatter to x1
   \<tr>
   for i = 1 to n
      lcX = alltrim( x1[i] )
      if ( empty( lcX ) )
         lcX = " "
      endif
      \\<td><<lcX>></td>
   endfor
   \\</tr>
endscan

\</table>
But back to objects...

>As rows are created a counter is incremented at the Table level.
>
>Good advice. Like I say, I am quite new to this stuff & trying to get a grip on the how & why of it all.
>
>Is the use of AddObject() common in these situations?


You might want to use a Collection array. Like a Form has a Controls[] collection, a PageFrame has a Pages[] collection. You can override the AddObject() method of your Table object to add a row to a Rows[] collection. It could be done like:
with this
   .nRows = .nRows + 1
   dimension Rows[.nRows]
   .Rows[.nRows] = CreateObject( "Row" )
endwith
During the Table.Destroy() you have to iterate through the Rows[] collection and do a .Rows[i] = .null. to clean up your object references. A Row object would have a Cells[] collection and understand how to add a new cell.

You could also do a runtime AddObject in Table like:
with this
   .nRows = .nRows
   lcRowName = "Row" + padl( .nRows, "0", 3 )
   .AddObject( lcRowName, "Row" )
endwith
This gives you a set of contained rows that are named Row001, Row002 etc. But a collection array is much more flexible.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Reply
Map
View

Click here to load this message in the networking platform