DEFINE CLASS myPrivateDSClass AS session PROCEDURE UseTable *!* By using the table inside a method of the session object, *!* you are working in the object's DataSession LPARAMETER tcTable IF NOT USED(tcTable) USE (tcTable) IN 0 ENDif ENDproc PROCEDURE Destroy CLOSE DATA ALL ENDprocTest code:
CREATE TABLE myDSTest (cTest C(10)) USE DBF() SHARED *!* CREATE TABLE makes an exclusively-used table. USE DBF() SHARED is *!* a good method for not having to remember the path to the table FOR i = 1 TO 10 INSERT INTO myDSTest ; VALUES (TRANSFORM(i)) ENDfor oDS = NEWOBJECT("myPrivateDSClass", "MyDS.prg") *!* NEWOBJECT allows you to specify a class in a program or other *!* location without the use of SET CLASSLIB TO ... ADDITIVE. oDS.UseTable("myDSTest") SET *!* The following line is needed to keep oDS in scope, so you can *!* see the datasession. SUSPEND