4D v16 R5 brought a significant improvement to the DIALOG command. An improvement that lays in the possibility of passing a new parameter “formData” of type object. It was great to hear that this new addition has been well received by 4D developers.
With 4D v20, two other commands are upgraded, Print form and FORM LOAD! The benefit will be just as great. The object’s content passed in the parameter will be directly exploitable in the printed forms or forms loaded in memory.
code SAMPLE
Print form
The PRINT FORM command is widely used by 4D developers thanks to its recent improvements.
The PRINT FORM command can now pass an optional parameter of type object accessible via the Form function in the invoked form. Either directly using the Form function as expressions for the form objects (Form.firstname / Form.lastname / etc.) but also when the on printing detail event is executed.
$formData:=New object()
$formData.lastname:="Smith"
$formData.firstname:="john"
$formData.request:="I need more COFFEE"
$h:=Print form("Print_obj"; $formData; Form detail)
Where the form “Print_obj” looks like this:
FORM LOAD
Following the same principle, the FORM LOAD command can now receive an object as a parameter. If it is passed (optional), then the content of this object can be exploited in different ways and modified during the execution of the on load event (only event managed and only inside a sequence OPEN PRINTING JOB / CLOSE PRINTING JOB).
OPEN PRINTING JOB
$formData.LBcollection:=New collection()
$formData.LBcollection.push(New object("reference"; "alpha"; "quantity"; 3; "total"; 120.99))
$formData.LBcollection.push(New object("reference"; "bravo"; "quantity"; 2; "total"; 599.99))
FORM LOAD("GlobalForm"; $formData) // $formData NEW !!!
$over:=False
Repeat
$full:=Print object(*; "LB") // the datasource of this "LB" listbox is Form.LBcollection
LISTBOX GET PRINT INFORMATION(*; "LB"; lk printing is over; $over)
If (Not($over))
PAGE BREAK
End if
Until ($over)
CLOSE PRINTING JOB
…where the “GlobalForm” contains a listbox “LB” using Form.LBcollection as a datasource.
Conclusion
This new programming possibility will save you time and make your code “lighter.”
As usual, feel free to share your feedback on the 4D forums. Looking forward to hearing from you!