The example of usage class DataEnvironment, defined in vcx-library in VFP 8.0 (and later)

In the subdirectory Libs\ the library deinlib.vcx, in which the following classes are defined:
Dataenvironment: de_base / (de_test)
Cursor: cur_base / (customer, orders, orderitems)
Relation: cust_order, ord_items

Pay attention, that:
- In the class cur_base, event Error is rewrite for handling error situations
- In the class de_base the event BeforeOpenTables() is rewrited, where in the code is used global  m.gcDatabase, if such variable is defined, for example:
m.gcDatabase = "c:\temp\data\testdata.dbc" (pay attention by lower case letters), the code of an example for all cursors instance of DE-class, the property Database is substituted on the value m.gcDatabase, if such variable is indefinite, otherwise nothing happens...
- In the subdirectory forms\ the form frm_detest.scx as example of use the class de_test (see values of properties: DEClassLibrary and DEClass), indicating, that all works how it's planned...:-) In event Load() the availability of the opened tables is inspected...
- In the subdirectory Reports\ the report rep_detest.frx lies, which used class de_rep (see Report/Properties...[DataEnvironment][Select] (in VFP 9.0) (pay attention, the correct location of the library deinlib.vcx should be indicated, in VFP 8.0 it is possible to see the code in the field Tag in last record if to open the file rep_detest.frx by command USE rep_detest.frx, after manual change of this field the recompilation COMPILE REPORT is required...) while main_rep.prg allows to view the report
- At last, in VFP 9.0 pay attention to the menu prompt Save As... At design the class DataEnvironment as in the design of any report, and any form
- See also MSDN: Visual FoxPro 9 Technical Articles / "What's New in the Visual FoxPro 9.0 Report Writer" 


For use datas from other directory, do following:
- Copy datas from C:\Program Files\Microsoft Visual FoxPro 8\Samples\Data\... In a new place for example, to c:\temp\data\ 
- Temporarily change the name of the directory C:\Program Files\Microsoft Visual FoxPro 8\Samples\Data for example to C:\Program Files\Microsoft Visual FoxPro 8\Samples\Data1
- From the command window enter:
m.gcDatabase = " c:\temp\data\testdata.dbc" 
- Start forms\frm_detest.scx
... How I hope, all works? :-)

(Direct "as is", all pathes to the data are determined to the data of an example VFP 8.0, i.e. C:\Program Files\Microsoft Visual FoxPro 8\Samples\Data\testdata.dbc, however in vcx the library as properties Database the database testdata.dbc registers as in "relative pathes", see in the field Properties in the vcx-file, if to open it as dbf [using a command USE deinlib.vcx]. So that it's most interquartile, that you will have at once error "Error instantiating cursor object...". If it's true so, define the global variable m.gcDatabase=" C:\Program Files\Microsoft Visual FoxPro 8\Samples\Data\testdata.dbc " through  Command window before attempt to start of the form forms\frm_detest.scx. If after that, the start of the form will happen is successful, it alone and will be by your test at "incorrect values" properties Database of all classes-cursors from deinlib.vcx. Further, edit for all classes Cursor in deinlib.vcx property Database to correct value and release the global variable m.gcDatabase [RELEASE m.gcDatabase]. How I hope, all works? :-)

Best regards.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Michael Drozdov, ICS Soft, Perm, Russia
My Page:  http://vfpdev.narod.ru/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

