Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Hey george - could you give me your views on this questi
Message
 
À
13/08/1998 15:26:23
Tim Hockin
Illinois State U - Residential Computing
Normal, Illinois, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00126656
Message ID:
00126886
Vues:
16
>>>I would like to check for a return value from a FORM.
>>> How would I do this?
>>> thanks
>
>I find myself doing this a lot. Here is how I do it.
>
>I have a modalForm class, which I base these forms on. It has a custom property of RetVal which has value .F.
>
>It also has two buttons (OK and Cancel).
>
>Cancel.Click() does
>********************
>THISFOR.RetVal = .F.
>IF (THISFORM.QueryUnload())
> THISFORM.RELEASE()
>ENDIF
>
>OK.click() is a stub for instances
>*********************
>
>modalForm.Unload() does
>*********************
>RETURN THISFORM.RetVal
>
>
>Now when I create a form based on this, I can put something like this in my OK.Click()
>**********************
>
>IF (THISFORM.QueryUnload())
> LOCAL oNew
>
> oNew = CREATEOBJECT("NewWhatever")
> oNew.Val1 = THISFORM.Object1.VALUE
> oNew.Val2 = THISFORM.Object2.VALUE
>
> THISFORM.RetVal = oNew
> THISFORM.RELEASE()
>ENDIF
>
>the NewWhatever class is a custom object, that has properties for holding however many different things I need to return (I use this method for creating new records in complex relations)
>
>in the caller I do:
>
>LOCAL oNew
>DO FORM FormNewWhatever TO oNew
>
>IF (TYPE("oNew") <> 'O')
> * user hit cancel - handle it
> RETURN
>ELSE
> * user hit OK
> * do something with the oNew values
> oNew.RELEASE() && or RELEASE oNew if you haven't added a release method :)
>ENDIF
>
>I have found this to work quite well. the only drawback is that you make a new custom class for every "newWhatever" class you need. If you only need to return 1 value, some simple changes make that more efficient.
>
>Tim


Just for my 2 cents worth....I usually use an object reference also as it allows for the capture and return of several possible parameters that a dialog form may need to get from a user.

Steve
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform