Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
RETURN value from a METHOD?
Message
De
28/10/1999 23:45:47
 
 
À
28/10/1999 22:11:03
Peter Brama
West Pointe Enterprises
Detroit, Michigan, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00283548
Message ID:
00283593
Vues:
8
>Is there a way to get a RETURN value from a METHOD?
>
>I have a METHOD on my form that I use to process a save routine. It NOW has a cancel option that I need to send back so that the subsequent calls in the "calling" method don't complete when CANCEL is selected.

What is it being returned to? If it's a modal form, you can pass back a value therough the Form's Unload method if invoked via DO FORM TO MyVar

You can create a form property and have the cancel button update the property value, which other things can check or return as they like.

A RETURN statement in the method can return a single value to a method invocation (you can pass an object ref this way, but don't make it a form property that you pass back via Unload or you'll have a dangling object reference) and will return a logical .T. if nothing is specified otherwise. The following is sick and stupid, but it shows how you can pass back things of different types to a method invocation:
* IN the form, a sneaky little method hides...
PROCEDURE RandomMethod
LOCAL uResult
uResult = NULL
DO CASE
CASE VARTYPE(ThisForm.cmdCancel) = 'O'
   uResult = thisform.cmdCancel && object ref
CASE DAY(DATE()) = 2 * INT(DAY(DATE())/2)
   uResult = "I'm even"  && string based on a number
CASE thisform.BackColor = RGB(0,0,255)
   uResult = "I'm blue behind all this"  && random
CASE thisform.ForeColor = RGB(0,0,0)
   *  uResult will be null if it gets here and the forecolor is BLACK
OTHERWISE
   uResult = Thisform.BackColor/ForeColor  && now you know why I check for 0
ENDCASE
RETURN uResult

* Somewhere else in the form lies this code...
MyVar = thisform.RandomMethod()
*  MyVar now has the return in it.
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform