>>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
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement