Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Andy Kramek
  Where is Andy Kramek?
 Hot Springs Village
 Arkansas - United States
 Andy Kramek
 To: Anil Tayal
  Where is Anil Tayal?
 Delhi
 India
 Anil Tayal
 Tags
Subject: RE: Passing array from a class to a UDF
Thread ID: 50678 Message ID: 50714 # Views: 1 # Ratings: 0
Version: Visual FoxPro 6 Category: Classes and Objects
Date: Sunday, September 05, 2004 2:30:00 PM         
   


Hi Anil

> I recently came upon a problem. I have a class based on the combobox. It has an array property called aValues. The rowsource of the combobox is this array. In the INIT of the class I want to populate the array with values so I have to pass it to a UDF. I do as follows:
>
> proc MyCombo.INIT
>
> set udfparms to reference
> fillvalues(.aValues)
> endproc

Nope! You cannot pass a property (of any sort) by reference, only by value.

There are two options:
[1] Pass a reference to the object itself and let the called routine access the property
FillValues( This )


[2] Copy the array to a variable and pass that by reference:
ACOPY( This.aValues, laVals )
FillValues( @laVals )
ACOPY( laVals, This.aValues )


And just as a by-the-way, there is no need to use SET UDFPARMS just to pass a value by reference, prefixing the name with the "@" sign does it.

In fact you really should not use SET UDFPARMS like this because it is a global setting and can affect the way in which certain native functions behave. That means that your called routine may not behave as you expected!

Regards
Andy Kramek
Microsoft MVP (Visual FoxPro)
Akron, OH, USA

ENTIRE THREAD

Passing array from a class to a UDF Posted by aktayal @ 9/4/2004 1:44:34 PM
RE: Passing array from a class to a UDF Posted by Eric den Doop @ 9/4/2004 1:56:05 PM
RE: Passing array from a class to a UDF Posted by aktayal @ 9/4/2004 2:07:24 PM
RE: Passing array from a class to a UDF Posted by Andy Kramek @ 9/5/2004 2:30:00 PM
Thanx a lot Sir Posted by aktayal @ 9/6/2004 8:13:21 AM
RE: Thanx a lot Sir Posted by Andy Kramek @ 9/6/2004 1:10:21 PM