Jeremy,
In the situation you describe I initialize the object that will be passed
to the Dialog first. Like so:
$formObj:= New object("listbox_1";New
Collection(100;200;300);"someObject";New Object("foo";"Hello world")
DIALOG("MyDialogForm";$formObj)
// Dialog is closed and $formObj contains any/every thing added to it or
edited in the Dialog
This also allows you to configure what's going to be in Form. Such as
various entity selections, lists or what not. In the example above your
form could have a collection based listbox whose datasource is
'Form.listbox_1' and it could display the 3 numbers. You could set this up
in the On Load form event also, of course.
And it works in a similar way with a subform:
$subformObj:= New object("listbox_1";New Collection(100;200;300))
Object get pointer(Object named;"subform_object")->:=$subformObj
OBJECT SET SUBFORM(*;"subform_object";"MyDialogForm") // subform_object is
an object type var
// formObj contains any/every thing added to it or edited in the subform
When the subform object is itself an object or collection Form, in the
context of the subform, takes on the value of the subform object.
The great thing about this is that the code for the actual 4D form runs
identically whether it's in a dialog or a subform at least with respect to
Form (the function).
But wait, there's more.
In the example right above let's say instead of $subformObj being a new
object I assign it some object already in the parent form:
Object get pointer(Object named;"subform_object")->:=Form.someObject
OBJECT SET SUBFORM(*;"subform_object";"MyDialogForm")
Now in the context of the subform Form contains a 'reference' (say that
with an accent like JPR) to 'someObject' which was originally defined
before the dialog was loaded. Let's say the user changes 'foo' to "Hello
everyone".
In the subform:
Form.foo = "Hello everyone"
In the parent form:
Form.someObject.foo = "Hello everyone"
I think this gives a whole new value to subforms. I can design forms to
deal with a particular task or set of data and use them as a dialog or open
the within a dialog without having to change the code. Have you ever wound
up, or come across, a form with 10+ pages? These are ugly and difficult.
Instead you could have one page with a subform.
And gee we could use some more words for describing these things.
On Mon, Apr 29, 2019 at 1:05 AM Jeremy Roussak via 4D_Tech <
[email protected]> wrote:
> Is it safe to use the object returned by the Form command as a means of
> passing data back to the caller? That is, should the method of the form
> opened in DIALOG regard its Form object as read-only, or is it allowed to
> alter it?
>
> At present, changing the values of the object passed by DIALOG works: the
> new values are available to the caller when the DIALOG command returns.
> It’s quite handy. But there’s nothing in the documentation, as far as I can
> see, to indicate whether this is sanctioned or likely to change.
>
--
Kirk Brooks
San Francisco, CA
=======================
What can be said, can be said clearly,
and what you can’t say, you should shut up about
*Wittgenstein and the Computer *
**********************************************************************
4D Internet Users Group (4D iNUG)
Archive: http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************