I've got a class named "x" from which 100 forms are inherited from. Each form has a (default) data-enviroment with some tables in it.
I've written a piece of code that should come into the "beforeopentables" method of the data environment of each form. I want to do this in de data environment of the class "x" so that it's automatically inherited to the 100 forms using the form class "x".
I found out that I could do this by using the property "DEClass" BUT when I do this, all existing content of the forms their data environment is lost :-S
Is there really no way to change the DE of the class without losing the content of the forms their existing data environment? (or another way to fill up the "beforeopentables" without having to edit all the inherited forms)
Your forms are actually DBF files with extension of SCX. You can do something like #DEFINE CRLF chr(13)+chr(10) USE YourForm.SCX LOCATE FOR BASECLASS='dataenvironment' IF 'procedure beforeopentables' $ lower(methods) && There is already something in the beforeopentables. Will need something more complex. ELSE REPLACE METHODS WITH METHODS+CRLF+'PROCEDURE BeforeOpenTables'+CRLF+'all your code goes here'+CRLF+'END PROC' ENDIF
use COMPILE FORM YourForm
and use ADIR to get a list of all SCX files and run the above code on them. BACKUP ALL FORMS BEFORE YOU DO THIS
I don't want to fill it once but I want my forms to use a data environment from a PRG or even better a class (DEClass)
When I now fill it in through the properties, I get the message that all my tables/properties/code in the current DE of all the inherited forms will be lost and I don't want that; i'm searching for another solution to use the DEClass.
Can I also fill in the DEClass property with your code without losing the existing tables in my DE? (I don't have code in the methods of the DE, only tables)
I allready thought about it too but I don't want that. Our project is still in development and we create new forms every day.. Our development team counts 5 persons. It will easily be forgotten to add that piece of code to new forms; especially because some developers don't use SQL Server and stay with Foxpro for their customers.
That's the reason why I want to put that piece of code in the "DEClass" or "DEClassLibrary" of my class.
I agree, a class is always better. One way to make sure is to check the forms in a project hook. Then that program can run automatically whenever you build a project.