Wouldn’t it be great if you could just open a form and pass it some parameters to initialize your form objects? What about being able to also get the data back to process, after it’s been modified by the user? 4D v16 R5 makes your coding so much easier by greatly simplifying communications with forms.
Until now, when you wanted to display data (not coming from the database itself, but computed or external) to multiple users, you had two options: either write complex code to handle data display in multiple processes, or create as many forms as necessary with a bunch of global variables. But you know that global variables are not an optimized way of coding, from a memory point of view.
So get rid of your complex code and global variables! With 4D v16 R5 you can just bind an object to your form and use it internally with the new Form command. Painless…and powerful!
Pass parameters to a form
It’s now possible to pass parameters in an object to a form using the DIALOG command. Any property of this object will then be available from within the form context via the Form command.
C_LONGINT($window)
C_OBJECT($address)
$address:=New object
$address.CompanyName:="4D"
$address.LastName:="Dupont"
...
$window:=Open form window("AddressForm";Movable form dialog box)
// The form is opened with the $address object in parameter
// This allows modifying the $address object in the form with the Form command
DIALOG("AddressForm";$address)
CLOSE WINDOW($window)
ALERT("New company name is:"+$address.CompanyName)
In the “AddressForm” form, you just need to use the Form command in the form object data source:
When the users close the dialog, the values they entered are available in the calling method via the $address object.
Pass parameters to a subform
In the same way that you pass an object to a form with the DIALOG command, you can also pass an object to a subform area using the property list. Then, you can use it in the subform with the Form command. In the example below, the InvoiceAddress object is bound to the subform.