Still struggling to communicate with some of my secondary forms. This problem, again, happens only in StartMode = 4. Everything is fine interactively.
LOCAL cUserReturn AS String
DO FORM <formName> WITH par1, par2 TO cUserReturn.
I get an error message that there is operand/operator type mismatch. I tried to define cUserReturn as Variant - the same thing. The expected type of return is String.
According to the Help FoxPro is supposed to create a return variable when it is not defined. I tried to leave it undefined only to get another message: cUserReturn not found. Catch-22.
I suspect there is something here I do not know. Perhaps the return variable must be of special type.
Thank you.

return from a form.
ion lucian
Cetin and Marcia hi,
I am answering to you both. I will take a look at the posts carefully but I want to mention that reviewing Fox samples I just came across a sample titled: "Passing parameters between forms."
It seems to me they accomplish it by using a SPECIAL OLE control. They call it C_Solutions1. The example has two forms but I could not get hold of the second form so far to modify it. It appears at runtime only (form me). But the code for the main form is available. It seems this control plays a crucial role. Otherwise why would they use it This is the only thing this form does: sending questions to another form ang getting answers and displaying them, e.g, "The user answered NO"
It does use a classical DO FORM clause:
DO FORM LOCFILE
("ParamAsk.scx") WITH cParam1, nParam2 TO nRetValueI want to get more into it. Perhaps using this control saves a lot of trouble.
Thanks.
bharathvv
Hi Cetin,
The secondary form is a modal form. There is this statement in the INIT() of the secondary form.
THISFORM
.Show(1)It is the last statement of the method. It follows about 30 other clauses like ADDPROPERY(), a SET PATH, a function call to an outside prg file to open up a table, the table fields are cleaned up, etc.
As far as I remember all my attempts to change it to modeless form lead to a breakdown in interactive mode, even before I did the build. Now it works well in StartMode = 0 but not in 4.
Thanks.
__ted_glaza
radone
Marvs
>Are you sure the problem is with the return value What are you passing for the parameters
And in which method are you returning the value
dmead001
Show(1) doesn't guarantee that it is modal. Are you sure it is modal When does it show the below messagebox(), after form is released or before
do form ... to cUserReturn
messagebox("On this line cUserReturn value is:"+transform(m.cUserReturn))
magiccode9
Alex,
The 'expected' parameters count may be more but not LESS. Extra parameters (or the ones that are omitted) that are not passed by the caller are implicitly set to .F.
Form.init gets the parameters and unload returns the value (and the form is modal).
local cUserReturn as String
in this line 'as String' part has no importance other than intellisense support and/or serving as a reminder what type it is. It is implicitly initialized to .F. and if your form doesn't return anything then its value is .F.
I wonder if you used it with a nonmodal form and it errors at a line after 'do form ...' call In this case the form being modeless code continues to run and called form is still 'loaded'. No return value from it.
bayu
It is interesting. I tried to pursue such approach weeks ago but then dropped it. Got distracted.
Thanks.
Tvercel
Tamar
SvenP
ajl
First I thought you were clairvoyant or something. I did notice a minor mismatch in terms of parameters after I read your post. The Init (in the secondary form) expects 8 parameters but I was passing only 7 to it. After I removed the extra one, things (bad) remained the same.
I am passing in 7 parameters. The first one is an integer, its meaning is delay: how long the form will remain open if I never touch any buttons on it. The other 6 are strings: all of them are messages like: "do you want to delete this or that " Actually in this particular instance all 6 strings are empty and only one parameter is not empty.
Thank you.
Michael Entin SSIS
The secondary form is a modal form. There is this statement in the INIT() of the secondary form.
THISFORM
.Show(1)This is not the best way to accomplish what you need to do. You should just set the child form's WindowType = 1-Modal in the property sheet and call it from the parent form. Alternatively, if you are instantiating this form as modeless in a different context, this is how I would do it:
DO FORM MyForm NAME loForm LINKED WITH SomeParameters NOSHOW
loForm.Show( 1 )
Then instead of releasing the child form qwhen the user clicks on the exit button, I would hide it. Then the calling form can pick off whatever values it needs like this:
loForm.SomeProperty
loForm.SomeOtherProperty
before it releases the Child form.
Do not forget to declare loform as a loacl variable.