Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DE defined in code - autoopen won't until .init
Message
De
21/08/2006 06:47:48
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
20/08/2006 15:42:49
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01147133
Message ID:
01147230
Vues:
28
>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		&& breaks here, because no tables are open
>(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
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform