Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Array property as a referenced parameter to a function
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00047926
Message ID:
00047929
Views:
42
>How can I send an array wich is a property of a form (ie: Thisform.aMyarray) to a function as a referenced parameter, I'm trying to do this: lnReturnedValue = MYFUNCTION(@ThisForm.aMyarray) but it doesn´t work
>
>I've been doing this but it can be a lot of overhead processing
>
>local laMyarray(1), lnReturnedValue
>=acopy(ThisForm.aMyarray,laMyarray) && copies the array to a temporary local variable
>lnReturnedValue = MYFUNCTION(@laMyarray) &&the function changes the array
>=acopy(paMyarray,ThisForm.aMyarray) && returns the temporary array to the property
>
>Any help?


SAMPLE CODE:
*in the Init of the form
DIMENSION this.TestArray[5]
this.testarray[1] = 'UN'
this.testarray[2] = 'DEUX'
this.testarray[3] = 'TROIS'
this.testarray[4] = 'QUATRE'
this.testarray[5] = 'CINQ'


*in the click method of a commandbutton
*Pass the object as first parameter
*pass the array name as second parameter
=MyFunction(ThisForm, 'TestArray')


**********
FUNCTION MyFunction
lparameters loObject, lcArrayName
lcMess=''

*pay attention to the macro syntax
FOR i = 1 TO ALEN(loObject.&lcArrayName,1)
   lcMess=lcMess+' '+loObject.&lcArrayName.[i]
ENDFOR
=MessageBox(lcMess)

***********

The msgbox show 'UN DEUX TROIS QUATRE CINQ'

Bye!
:)
If we exchange an apple, we both get an apple.
But if we exchange an idea, we both get 2 ideas, cool...


Gérald Santerre
Independant programmer - internet or intranet stuff - always looking for contracts big or small :)
http://www.siteintranet.qc.ca
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform