>I want to return a value from a form which is instatiated modal form a class but it doesn't work because I get the returnvalue back of the show method :
>
>oMyForm=createobject("Myform")
>nReturnvalue=oMyform.show(1) && can't use .visible and .windowtype because it has to be modal
>
>I have an OK and Cancel button that release the form but I don't manage to alter the show's returnvalue. It seems that the value I get back is the one at 'SHOW' time, not at 'RELEASE' tiem.
>
>Any ideas ?
Pascal,
I wouldn't make it hard for myself using modal form's return value. Instead would pass a reference of caller to called form (modal or not). Called form then could access and set properties of caller. However as a workaround you could do it like this :
nRetVAlue = 0
oMyForm=createobject("Myform") && oMyForm could now access and set nRetValue
oMyform.show(1)
? nRetValue
This sample combines both approaches :
oCaller = createobject('CallerObject')
oMyForm=createobject("Myform",oCaller)
nReturnvalue=0
oMyform.show(1)
? nReturnValue, oCaller.RetValue
define class CallerObject as custom
RetValue = .null.
enddefine
define class myForm as form
oCaller = .null.
procedure init
lparameters toCaller
this.oCaller = toCaller
endproc
procedure unload
this.oCaller.RetValue = 'hello'
nReturnValue = 8
endproc
enddefine
Note that passing ref. approach let's you multiple values returned, and called form could call any event,method from caller.
Cetin