Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Array properties as parameter

Status
Not open for further replies.

Nro

Programmer
May 15, 2001
337
CA
Hi.

I have an old problem and I was wondering if somebody has solve this.

In VFP 7.0 sp1, I have a class with an array property :

orcCust.aBrowseFld[5,10]

I want to pass this array to a function (or method) as a referenced parameter like this :

THIS.set_swapCol(THIS.aBrowseFld, 2, lnAcol)

I cant't use @ (@THIS.aBrowseFld) to pass it as reference, I tried

SET UDFPARMS TO REFERENCE

but still pass the first element of the array only. The only solution I find is to dimension a dummy array, copy the original into the dummy array and then pass it to the function as a reference. I have to copy it back to the original.

DIMENSION laBrowseFld[ALEN(THIS.aBrowseFld,1), ALEN(THIS.aBrowseFld,2)]
ACOPY(THIS.aBrowseFld, laBrowseFld)
THIS.set_swapCol(@laBrowseFld, 2, lnAcol)
ACOPY(laBrowseFld, THIS.aBrowseFld)

Too much work for me.

Is it possible to do it with less code ?

Thanks

Nro

 
I admit I'm confused both about just what you're trying to do and what the problem is. yes, when you pass an array by reference you're just passing the starting point of the array in memory. But once it's passed I'd assume you could get any particular values you want using the standard array manipulation methods. Just what are you doing in .set_swapCol which causes an error? Dave Dardinger
 
Hi Dave.

My question is just about passing an array that is a class property (THIS.aBrowseFld), like this ;

THIS.set_swapCol(@THIS.aBrowseFld, 2, lnAcol)

but this syntax give me an error.

Thanks
 
Why pass parameters? If you're just calling a class method, that method can access the array property normally. It doesn't need a parameter passed to it.

Ian
 
Maybe he has several arrays and one method... maybe the array is a property from a different object than the method is in; there are valid reasons to do this, I'd be interested to know how, too!
 
I see what you're saying. VFP thinks "thisform" is an alias with "aBrowseFld" as a field name. The only suggestion I have is to build a temporary array from the class's array and send THAT.

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top