Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Data Environment vs Hard Coding Open of Tables
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00087199
Message ID:
00088214
Vues:
40
Steve,

You deserve a head start:) . Take a look at my deBase class, the base class of my dataenvironment class. The inherited classes are instantiated by the load method of forms. This is done at the base level as well.

As you see it enables you to (1) clone a table if that is what you want, or combine fields from open tables (mind you the DE is responsible for opening the tables) or create you fields by supplying the type you require. (I admit that the name of the method could have been a bit shorter, but that is nothing a good macro cannot solve!).

What you do after that is entirely up to you. You can populate it with empty records and submit that to a grid, or you can bind controls in your form to a one record cursor.

HTH,

Marc
***
*** -------------------------
***

define class deBase as custom

	dime aCursorStructure(1,16)
	nCursorFields= 0	
	oForm= .t.					
	dime aCursors[1]
	nCursors= 0

	*---------------------
	procedure Clone(c1,c2)
	local a[1],b[1]

	select (c1)
	=aField(a)
	create cursor (c2) from array a
	append blank
	
	for each c in this.aCursors
		if type("C")= "L"
			exit
		endif
		if c= c2
			return
		endif
	endfor
	
	this.nCursors= this.nCursors+1
	dime this.aCursors[this.ncursors]
	this.aCursors[this.nCursors]= c2
	
	*-------------------------------------------------
	procedure AddToCursorStructure(cTable,cField,cType,nL,nD)
	local cType
	
	this.nCursorFields= this.nCursorFields+1
	dime this.aCursorStructure(this.nCursorFields,16)

	
	if !empty(cTable)
		select (cTable)
		=afields(aCursorStructure,cTable)
	
		for n=1 to alen(aCursorStructure,1)
			if upper(aCursorStructure(n,1))= upper(cField)
				for n1= 1 to 4
					this.aCursorStructure[this.nCursorFields,n1]= aCursorStructure[n,n1]	
				endfor
			endif
		endfor
	else
		this.aCursorStructure(this.nCursorFields,1)= cField
		this.aCursorStructure(this.nCursorFields,2)= cType
		this.aCursorStructure(this.nCursorFields,3)= nL
		this.aCursorStructure(this.nCursorFields,4)= nD
	endif		
	this.aCursorStructure[this.nCursorFields,5]= .f.
	this.aCursorStructure[this.nCursorFields,6]= .f.
	for n1= 7 to 16
		this.aCursorStructure[this.nCursorFields,n1]= ""
	endfor
	
	*-------------------------------------------
	procedure CreateFromCursorStructure(cCursor)
	create cursor (cCursor) from array this.aCursorStructure
	this.nCursorFields= 0

	this.nCursors= this.nCursors+1
	dime this.aCursors[this.nCursors]
	this.aCursors[this.nCursors]= cCursor

	*------------------------------------
	procedure Clear
	
	for each C in this.aCursors
		select (C)
		if C=="GL"
			scatter memvar memo blank
			gather memvar memo
		else
			zap
		endif		
	endfor
	unlock all
	*------------------------------------
	procedure Destroy

	this.DestroyCursors()

	*------------------------------
	procedure DestroyCursors()
	local c
	if this.nCursors= 0
*		error "Program Error: DE did not register cursors"
		return
	endif

	for each C in this.aCursors
		if used(C)
			select(C)
			use
		endif
	endfor
		
enddefine

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform