Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating collection classes
Message
De
01/05/2001 15:15:16
Phillip Perkins
Technology Consulting, Inc.
Louisville, Kentucky, États-Unis
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00501934
Message ID:
00502181
Vues:
21
I think I'm onto something here, but it takes a little bit of accepting some drawbacks. I am creating a class (I'll just give some 'for instances' here). I'll call the class MainClass. Then in my MainClass I want a collection of objects that I can reference by something like a collection class. Unfortunately, VFP doesn't really give you a Collection class that you can subclass (I can't create a class with a collection of objects that I can reference like things.count and things[1].name). Then in my MainClass I add some objects: This.AddObject("object1", "myobject"). I already have a property that I created in the class designer (things[1]). So all I have to do now is make a reference to my newly created object: This.things[1] = this.object1 . So now I have a reference to my object through my parent class: MainClassObject.things[1].value or MainClassObject.things[2].name . I have some other methods on my MainClass that add and remove objects and makes all the references.

The reason that I want to do this is that I want an extensible class that I can instantiate to use to attach to VFP data through a network connection on a Linux machine. I built a Perl server that attaches to the VFP data, builds a hash table to reference the queried data, and moves through the data via my own special protocol ("MOVE NEXT", "MOVE TOP", "QRY SELECT * ...", "FIELDS[1].NAME", etc.). The class is just an interface to the protocol but with methods and properties so the "programmer" can get to the data in an OO fashion. Instead of bringing all the data to the client machine (which through a POTS 'net connection would be terribly slow), the data would be picked a little at a time. The idea is more like ADO, but significantly different in the actual function. In the end, I don't have to mess with all the ODBC and stuff on the client side 'cause I'm just working through protocol on an IP:Socket deal. It's actually quite groovy.

Phillip

>Hi Phillip,
>
>>Just brainstorming here, but do you think that it would be possible to create an array of references to objects and then use the properties and methods of those individual objects by dereferencing through the array references?
>>
>>For example:
>>
>>DIMENSION myarray(10)
>>myarray(1) = CREATEOBJECT("Object1", "MyClass")
>>...
>>
>>and then myarray(1).Value???
>>
>
>Yes It is
>
>DIMENSION MyArray(1)
>
>MyArray(1) = CREATEOBJECT("MyItem")
>MyArray(1).value = "a"
>? MyArray(1).value
>
>DEFINE CLASS MyItem AS Custom
>
> Value = .NULL.
>
>ENDDEFINE
>
>>But then, how would I create a class that holds all the created objects and be able to reference them such as Parent.MyObjects(1).Value???
>>
>
>I am not sure I understand what you want but MyObjects(1).Parent.Value is possible with VFP
>
>Marcel
"D'OH!" --Homer Simpson
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform