Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to pass an array and return array from a form
Message
 
À
02/03/2003 18:49:01
Mike Yearwood
Toronto, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00759681
Message ID:
00760202
Vues:
16
Mike,

Does the called form need the return ThisForm.MyParms?
TIA.

>Hi Allan
>
>Jim must've made a typo. It's not DO FORM WITH loParm TO loParm. loParm is a parameter object that exists even after the form exists. If you put TO loParm, the return value of the form will replace loParm with the return value of the form.
>
>You can read and write the parameters in the parameter object from your form and upon exiting the form, the parameter object has those values.
>
>>Jim,
>>
>>I tried your suggestion and received an error 'loParam not an object' when I attempted to reference it upon return to the calling program.
>>
>>However, if I define a class in my 'set procedure' program and add the object in the calling program based upon that class, I do not get the error. Also, in this case I didn't use the 'return thisform.loParam' in the called program.
>>
>>I really appreciate all of the suggestions in this thread.
>>Thanks once again.
>>>>Jim,
>>>>
>>>>That wouldn't work with local variables would it?
>>>>I would have to use private?
>>>>Tks.
>>>>
>>>
>>>Alan,
>>>
>>>Passing by reference and variable scoping are tow different things. You could create a private array prior to calling your form and then address that array in the form, but that presents a whole mediad of potential problems.
>>>
>>>By far, the best solution ot your probelm is to use a parameter object;
>>>
>>>
>>>
>>>loParm = CreateObject("Relation")
>>>loParm.AddProperty("MyArray(1,2)")
>>>DIMENSION loParm.MyArray(2,3)
>>>
>>>FOR lnCnt1 = 1 TO 2
>>>   FOR lnCnt2 = 1 TO 3
>>>      loParm.MayArray(lnCnt1,lnCnt2) = SUBSTR("ABC",LnCnt2,1)
>>>   ENDFOR
>>>ENDFOR
>>>
>>>* For this to work the form must be modal becasue only m odal form's can return values
>>>DO MyForm WITH loParm TO loParm
>>>
>>>* Now loParm has a property named MyArray that has whatever the fomr put there for values.
>>>
>>>
>>>In the form's code;
>>>
>>>
>>>PROCEDURE Init
>>>  LPARAMETERS poParms
>>>  Thisform.AddProperty("MyParms")
>>>  Thisform.MyParms = poParms
>>>ENDPROC
>>>
>>>
>>>Then within the form you use Thisform.MyParms.MyArray(x,y)
>>>
>>>
>>>PROCEDURE Unload
>>>RETURN ThisForm.MyParms
>>>
Regards,

Allan Coganovitch
allanc@proven-solutions.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform