Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing parameter and array to a form
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00244689
Message ID:
00244938
Views:
16
>I Got two question
>1 - When i passe a parameter with Do form command
> How can i make my parameter visible in the receving form with out defining a Public variable and asing the parameter value to the public variable
>

You have to save it as a form property, since the value goes out of scope immediately after the Init completes.

>2 - Can we passe array to a form. With the Do form command

Yes -m by default, all parameters passed by DO are by reference, so that if you have an array aMyArray[], you can pass it to the form's Init by:

DO FORM MyForm WITH aMyArray

In the Init, you'll need a PARAMETER or LPARAMETER statement, and in order to avoid a warning at compile time, an EXTERNAL ARRAY statement. Your Init code might start something like:

LPARAMETER taInArray
EXTERNAL ARRAY taInArray

You can then copy the passed array to a member array property. You can get the dimensions of the passed array using ALEN(). Again, you have to save it to a Form member array, because the parameter or lparameter will go out of scope as soon as the Init method completes.

A better way to pass arrays (or really anything) by reference is to create a parameter object - an object that contains the things you want passed in or out of the form. You save the object reference to a member property, and then anywhere within the form, you can references the members of the passed object through the form property holding the object reference. If you need to change the values in the array and pass them back from the form, simply modify the content of the object; on exit from the form, the object reference still exists, and any changes are then available to the calling routine.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform