Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Array as property in VFP6?
Message
De
14/01/2004 20:38:27
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00865239
Message ID:
00866963
Vues:
26
>Hey Jason,
>
>Thanks works like a charm. Now I have another question, How can I return the entire array? Will it have to be passed to the component as a parameter?
>
>Thanks!

Adam,

Depends on how you are trying to use the array. If the array is created in a parent object and passed to a child object by reference, there is no need to return the array as oChild will be modifying oParent.MyArray directly. If the array is created in oChild and needs to be sent to oParent...I'd recommend creating an object to return array and non-array variables.

Check this out....
**************************************************
DEFINE CLASS cparent AS form


	DoCreate = .T.
	Visible = .T.
	Name = "cparent"


	ADD OBJECT cbutton1 AS commandbutton WITH ;
		Top = 196, ;
		Left = 140, ;
		Caption = "Get Values", ;
		Name = "Cbutton1"


	ADD OBJECT ctextbox1 AS textbox WITH ;
		Left = 155, ;
		Top = 30, ;
		Name = "Ctextbox1"


	ADD OBJECT ctextbox2 AS textbox WITH ;
		Left = 155, ;
		Top = 71, ;
		Name = "Ctextbox2"


	ADD OBJECT clabel1 AS label WITH ;
		Caption = "Array Value (2,3)", ;
		Left = 60, ;
		Top = 33, ;
		Name = "Clabel1"


	ADD OBJECT clabel2 AS label WITH ;
		Caption = "String Value", ;
		Left = 83, ;
		Top = 74, ;
		Name = "Clabel2"


	PROCEDURE cbutton1.Click
		  local loParmObject
		  
		  do form Child to loParmObject
		  
		  thisform.cTextBox1.value = loParmObject.aArrayVar[2,3]
		  thisform.cTextBox2.value = loParmObject.cStringVar
		  
	ENDPROC


ENDDEFINE
**************************************************
**************************************************
DEFINE CLASS cchild AS form


	Top = 0
	Left = 0
	DoCreate = .T.
	Visible = .T.
	WindowType = 1
	Name = "cchild"


	ADD OBJECT cbutton1 AS button WITH ;
		Top = 202, ;
		Left = 142, ;
		Caption = "Done", ;
		Name = "Cbutton1"


	ADD OBJECT clabel1 AS label WITH ;
		Caption = "String Value", ;
		Left = 32, ;
		Top = 21, ;
		Name = "Clabel1"


	ADD OBJECT clabel2 AS label WITH ;
		Caption = "Array Values", ;
		Left = 9, ;
		Top = 57, ;
		Name = "Clabel2"


	ADD OBJECT atextbox1 AS textbox WITH ;
		ControlSource = "thisform.oParmObj.cStringVar", ;
		Left = 103, ;
		Top = 18, ;
		Name = "Atextbox1"


	ADD OBJECT clistbox1 AS listbox WITH ;
		ColumnCount = 5, ;
		ColumnWidths = "40,40,40,40,40", ;
		RowSourceType = 5, ;
		RowSource = "thisform.oParmObj.aArrayVar", ;
		Height = 126, ;
		Left = 84, ;
		Top = 58, ;
		Width = 249, ;
		Name = "Clistbox1"


	PROCEDURE Unload
		  local loParmObj
		  
		  loParmObj = thisform.oParmObj
		  
		  return loParmObj
	ENDPROC


	PROCEDURE Load
		  local lnCnt, lnRow, lnCol, loParmObj
		  
		  thisform.AddProperty('oParmObj')
		  
		  loParmObj = newobject('cParmObj', 'classes\serial')
		  thisform.oParmObj = loParmObj
		  
		  for lnCnt = 1 to alen(thisform.oParmObj.aArrayVar,0)
		    lnRow = asubscript(thisform.oParmObj.aArrayVar, lnCnt, 1)
		    lnCol = asubscript(thisform.oParmObj.aArrayVar, lnCnt, 2)
		    thisform.oParmObj.aArrayVar[lnRow, lnCol] = lnCnt
		  endfor
		  
		  thisform.oParmObj.cStringVar = 'Groovy!'
		  
	ENDPROC


	PROCEDURE cbutton1.Click
		  
		  thisform.Release()
	ENDPROC


ENDDEFINE
**************************************************
Of course, to get this to work, you'll need to create these classes then do....
create form child as cChild from MyClassLib
create form parent as cParent from MyClassLib
then save both forms and run the parent.

Long answer but the concept is pretty groovy.

Jason
---------
Single field, surrogate primary keys....because it's sexier!

Third normal form is more than just a good idea.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform