PRB: Cannot Pass an Array Member to a ProcedureID: Q130224 3.00 WINDOWS
The information in this article applies to:
SYMPTOMSAn array that is declared as a member of a class cannot be passed by reference to a function or a method. For example, if you declare an array as a property of a form, the error "Alias 'this' is not found" is displayed when a method is called as follows:
CAUSEVisual FoxPro always passes object properties by value. Object properties cannot be passed by reference.
WORKAROUNDAn alternative is to pass the array name to a method, and manipulate the array or a copy of the array. The following example code defines a form with a command button. When the command button is clicked, a function is called that adds 10 to each element of an array declared as a property of the command button. The same method can be used in the Form Designer.
Sample CodePUBLIC oform oform=CREATEOBJECT('frmtest') oform.Show DEFINE CLASS frmtest AS FORM ENDDEFINE
DEFINE CLASS cmd AS COMMANDBUTTON DIMENSION aprop[10] PROCEDURE init ENDPROC
PROCEDURE click ENDPROC
* Two parameters are passed to the procedure: a reference to the object, * and the array name. PROCEDURE ADDEM ENDPROC
ENDDEFINE
STATUSThis behavior is by design. Additional reference words: 3.00 VFoxWin KBCategory: kbprb KBSubcategory: FxprgClassoop
|
Last Reviewed: May 22, 1998 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |