>I have a form class with DeClass and DeClassLibrary set to a dataenvironment class defined in a .prg file. Like this:
>
>
Define Class Deeventbrowser as dataenvironment
>Top = 196
>Left = 5
>Width = 668
>Height = 506
>DataSource = .NULL.
>
>Add Object curEvents as cursor with ;
> Top = 20, ;
> Left = 10, ;
>... (dozen more cursors here)
>
>...
> PROCEDURE Init
> Locate
>(more code here)
>
> PROCEDURE BeforeOpenTables
> Set Date ANSI
> Set Century on
> Set Mark to "-"
> Set Talk Off
> Set Nulldisplay To "---"
> Set Safety Off
> Set Exclusive Off
> Set Deleted On
> ENDPROC
>
> PROCEDURE Cursor3.Init
> * just a little nothing
> ENDPROC
>EndDefine
>
>This is actually an export of an old DE which used to be in a form. There, the .BefOT code ran first, then the tables opened, then form.load, then all the controls instantiated, then de.init ran, then form.init. Which was fine.
>
>With this way of creating a form's DE, de.init runs before anything else, then the tables open, then the de.beforeopentables, form.load, controls' inits, form.init etc.
>
>This of course breaks the code - the code in old (scx-based) DE.init ran
after the tables were opened. Now .autoopentables (which is .t., checked in the debugger) doesn't mean what it used to mean. Is there any additional setting in the DE class which would make it open the tables like before, or rather run its .init after the .beforeopentables()?
>
>Any other workaround?
>
>update: one workaround I found was to move the code from de.init to de.afteropentables. Not too elegant, still looking for a better one.
Dragan,
Another workaround is to call the opentables() explicitly with a flag. ie:
Define Class Deeventbrowser as dataenvironment
TablesLoaded = .F.
Procedure Init
this.OpenTables()
locate
endproc
Procedure OpenTables
if this.TablesLoaded
nodefault
endif
this.tablesLoaded = .T.
endproc
Cetin