Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Code expansion error
Message
 
À
01/10/2012 16:39:38
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01554057
Message ID:
01554083
Vues:
45
>>Hi Tommy,
>>
>>I see you already have your answer but, why isn't SocketWrench an Array, which would be much easier to handle?
>
>Can you educate me on this please? Considering that each SocketWrench appears to be an object on a page, how would you handle it as an array?
>
>.........Rich


Hi Rich,

Not sure what you see as a problem, maybe I am missing something?

The only issue I see is that you need to remember to clean up the array in the destroy if it is pointing to other objects, otherwise it is just another property of an object, a very crude sample, using empty object as the reference (warning, code like the one I am posting should never be used, as I am not declaring any variable, using hard-coded values where I shouldn't, no error handling etc, just trying to show that you can use the array):
loForm		= CreateObject('myForm')

for i = 1 to 18
	? loForm.myPageFrame.Page1.SocketWrench[i].Name
endfor
	
define class myForm as Form
	add object myPageFrame as PageFrame
	
	function myPageFrame.init()
		this.PageCount = 1
		AddProperty(this.Page1, 'SocketWrench(1)')
	endfunc
	
	function init()
		dimension this.myPageFrame.Page1.SocketWrench(18)
		for i = 1 to 18
			this.myPageFrame.Page1.SocketWrench[i] = CreateObject('Empty')
			AddProperty(this.myPageFrame.Page1.SocketWrench[i], 'Name')
			this.myPageFrame.Page1.SocketWrench[i].Name = 'mySocketWrench' + Transform(i)
		endfor
	endfunc
	
	procedure Destroy()
		for i = 1 to 18
			? 'Destroying ' + this.myPageFrame.Page1.SocketWrench[i].name
			this.myPageFrame.Page1.SocketWrench[i] = null
		endfor
	endproc
enddefine
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform