Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
DO FORM vs. CREATEOBJECT
Message
 
À
18/05/1998 14:07:25
Ryan Hirschey
Federal Reserve Bank of New York
New York City, New York, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00100139
Message ID:
00100168
Vues:
58
>>>How would I convert "DO FORM xxx WITH yyy TO zzz" To "ofrm = CREATEOBJECT()"
>>>
>>>How do I return a value from an object when the object is created with "CREATEOBJECT()". Thanks.
>>
>>Just to add to what Ryan said. Be sure you check to make sure that the user didn't close the form using the Close button in the upper right hand corner. If they did, the variable will still evaluate to an object, but it will be null, and you won't have access to any of the properties.
>
>
>Good point. I was wondering if I was missing something. Here's a question, then. If the goal is to use a modal form and allow the user to choose some parameters and then pass them back to the calling routine upon closing, does CREATEOBJECT not handle this gracefully? In other words, would DO FORM be more appropriate, or can any return values from a form be read from a calling routine? If the return values can be read from the calling routine, how would this be done? Createobject seems great when you have one routine that starts and shuts down the object programmatically, but what would you do for the 'mixed' scenario you describe in which a routine starts an object, but something on the object itself closes it?

If the variable being returned isn't an array, then IMHO, DO FORM is more graceful. However, if you want to return a number of items, via an array, then there's no choice but to make it a property of the form, and access it after the form is closed. This can also be done, via DO FORM with the NAME clause to create a variable reference. However, this variable will be subject to the same problems that you would have with one created from a class library. In other words, it should be checked via IF TYPE('oForm') = "O" AND NOT ISNULL(oForm)... The variable it returns, should contain the same value as it would have if the user canceled.

Personally, and especially with modal forms, I favor DO FORM rather than CREATEOBJECT() since the former tends to be slight faster (the system doesn't have to create a copy of the object).
George

Ubi caritas et amor, deus ibi est
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform