PRB: Cannot Pass Array Property of Form by Reference to OLE DLL (194514)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 6.0
This article was previously published under Q194514 SYMPTOMS
Trying to pass an array property of a form by reference to a COM server
results in the following error:
"Alias 'THISFORM' is not found"
RESOLUTION
There are two methods of working around this limitation:
- Use the ACOPY() function to copy all the data from the array property to
an array variable, then pass the array variable by reference.
-or-
- If having the array be a property is not a necessity, eliminate the
array property, and dimension an array variable in the Init of the form.
Pass that array by reference to the object.
Example 1:
Modify the btnOne.Click Method to the following:
***************Start Code Workaround 1****************
PROCEDURE btnOne.CLICK
THISFORM.oArrTest=CREATEOBJECT('frmArray.ArrTest')
IF TYPE('thisform.oArrTest')#'O' then
WAIT WINDOW 'Did not instantiate'
RETURN
ENDIF
COMARRAY(thisform.oArrTest,11)
ACOPY(THISFORM.MyArray,aTemp)
THISFORM.oArrTest.modarray(@aTemp)
DISPLAY MEMORY LIKE aTemp
ENDPROC
PROCEDURE btnClose.CLICK
CLEAR EVENTS
RELEASE THISFORM
ENDPROC
**********End Code Workaround 1********************
Example 2:
Replace the Client code with the following:
***************Start Code Workaround 2********************
x=CREATEOBJECT("Test1")
x.VISIBLE=.T.
x.SHOW
READ EVENTS
DEFINE CLASS Test1 AS FORM OLEPUBLIC
oArrTest=.NULL.
ADD OBJECT btnOne AS COMMANDBUTTON WITH TOP = 1, ;
CAPTION = 'Test Array'
ADD OBJECT btnClose AS COMMANDBUTTON WITH TOP = 25, ;
CAPTION = 'Close'
PROCEDURE INIT
DIMENSION aMyArray(5,1)
I=1
FOR I = 1 TO 5
aMyArray(I)='Form'
ENDFOR
ENDPROC
PROCEDURE btnOne.CLICK
THISFORM.oArrTest=CREATEOBJECT('frmArray.ArrTest')
IF TYPE('thisform.oArrTest')#'O' then
WAIT WINDOW 'Did not instantiate'
RETURN
ENDIF
COMARRAY(thisform.oArrTest,11)
THISFORM.oArrTest.modarray(@aMyArray)
DISPLAY MEMORY LIKE aMyArray
ENDPROC
PROCEDURE btnClose.CLICK
CLEAR EVENTS
RELEASE THISFORM
ENDPROC
ENDDEFINE
*************End Code Workaround 2*************************
STATUS
This behavior is by design.
Modification Type: | Major | Last Reviewed: | 8/24/1999 |
---|
Keywords: | kbprb KB194514 |
---|
|