` Printed Icetips Article

Icetips Article



ABC: Passing Relation Manager to a class
1999-07-21 -- Phillip Carroll
 
Newsgroups: topspeed.topic.oop

> I have a file called PRODUCTS.DAT, my app is PSYSTEM.APP. So when i compile,
> this is generated in PSYSTEM.CLW:
>
> Access:PRODUCTS    &FileManager
> Access:PRODUCTS    &RelationManager
>
> I am creating a class that will do some I/O on PRODUCTS so i want to still
> make use of the instance of  Access:PRODUCTS created without having to
> create a different on in the .INI,.CLW of my class so that i can use
> something like  Access:PRODUCTS.Insert().
>
> Of course, i get compiler error when the compile hits the .clw containing
> class since it doesn't know what  Access:PRODUCTS means. The bottemline is
> that i am trying to have just one declaration of Access:PRODUCTS. Am i
> missing something?


Pass an object reference to your class. However, I suggest passing a Relation
Manager object reference instead, so that you will have the ability to use
Relation Manager methods as well as File Manager methods. The basic steps are
outlined below.

Add a property to your class properties:
MyFile   &RelationManager

Have your Init method include another parameter:
MyClass.Init   PROCEDURE(RelationManager MyFile, )
   CODE
     Self.MyFile &= MyFile

After instantiating an object in your class, Initialize it with
   xxx.Init(Relate:Products, other parameters)

Your other methods will be able to call nonprivate nonprotected methods using:
  Self.Myfile.Method(parameters) ! Relation Manager methods
  ! The Relation Manager Me property is the File Manager
  Self.MyFile.Me.Method(parameters) ! File Manager methods

HTH

Phil Carroll



Printed May 6, 2024, 9:51 am
This article has been viewed/printed 35120 times.
Google search has resulted in 5 hits on this article since January 25, 2004.