Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
More array passing...
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00276579
Message ID:
00276624
Vues:
29
I've never done any array passing before, and I've never used the @ symbol. I've read quite a bit on the UT about using @ to pass a reference to a variable, and I think I understand the concept (I don't know C very well, but I'm assuming it's similar to a pointer).

I used the solution Roi provided below and it works fine. The problem I was having trying to use the @ to pass an array was this: I couldn't pass a reference to an array to a form . All the examples I saw were passing a reference to a procedure. If you try to call a form like this:
DO FORM myForm WITH @aArray

FoxPro complains. (It did for me anyway...)

I've not had many complaints about FoxPro, but it seems to me this is one short-comming. If they are only going to let you return one value back from a form, they should let you return any type of value, arrays included. I think it's a bit odd that you have to create an object to contain the array, and then pass that back.

*shrug* It works. I keep telling myself "Why ask why?"


>i thought you could only pass arrays using the @ symbol
>
>>Roi -
>>
>>I think a couple of the threads that I found on this subject tried to explain what you did below. I couldn't understand what they were saying though. Your explanation makes sense to me and I think I like passing the array that way better than making it public.
>>
>>Thanks for the very straight-forward explanation!
>>
>>
>>>Hi Kile,
>>>
>>>You can't return an array. You can either make it public like Jeff said or use an object to hold it.
>>>
>>>From the method that calls the form.
>>>
>>>oParam = newobject('custom')
>>>oParam.AddProperty('aArray[ 1 ]')
>>>*...Add some stuff to the array
>>>Do Form MyForm with oParam
>>>
>>>In MyForm add a property called MyParam (you add this on the fly if you want)
>>>in the init of MyForm, catch the oParam object
>>>lparameters oPar
>>>thisform.oParam = oPar
>>>*....Do stuff to the array
>>>
>>>That's it. Since the array is local to the method that calls the form, it will still be there when MyForm has been destroyed. If you change the array in MyForm you are actually changing oParam.
>>>
>>>hth
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform