Returning a Value from a Modal Form

The following is an example wrapper class used to allow forms to return values. It uses a simple naming convention that the return value memvar must be called luRetValue. Since dialog forms which return values are normally modal, the example assumes that the form called is modal.


*-- The DoForm class is the wrapper class and 
*--  the DoForm UDF is used to call it.
*-- Simply set memvar luRetValue in any code *-- snippet within a form/control method.
*-- The exit code for the form should be *-- RELEASE thisform *and* CLEAR EVENTS.
*-- This example set would need to be enhanced *-- to support parameter passing to the form.
? DoForm("MyForm.SCX") && Form MyForm.SCX should set && luRetValue for the && return value.
RETURN
FUNCTION DoForm(tcFileName)
LOCAL oDoForm
oDoForm=CREATEOBJECT('DoForm',tcFileName)
RETURN oDoForm.Show()
DEFINE CLASS DoForm AS Custom
cFileName=''
FUNCTION Init(tcFileName)
this.cFileName=tcFileName
RETURN .T.
ENDFUNC
FUNCTION Show
PRIVATE luRetValue
luRetValue=.T.
DO FORM (this.cFileName)
READ EVENTS
RETURN luRetValue
ENDFUNC
ENDDEFINE