Tech Tip: Passing Data to new Forms
PRODUCT: 4D | VERSION: 16R5 | PLATFORM: Mac & Win
Published On: February 15, 2018
4D v16R5 has updated the DIALOG command to accept a new thrid optional parameter. This parameter accepts a 4D Object and passes it onto the new Form displayed. The data can then be accessed through the new Form command, which returns the object and can also be used with dot notation as the object.
This will make it easier to send data to forms that are reliant on varying data.
Example:
Some code can be ran to obtain a time and date then stored into an object such that
$object_ob = {"Date" : "01/01/2018" , "Time" : "12:30PM"}
The data can then be sent to a new window using the following 4D code:
C_LONGINT($win_l) $win_l:=Open form window("Form1") DIALOG("Form1";$object_ob) CLOSE WINDOW($win_l) |
On the form, the object can then be accessed using the Form command.
C_DATE($date_d) C_TIME($time_ti) C_OBJECT($passedData_ob) $date_d:=Form.Date $time_ti:=OB GET(Form;"Time") $passedData_ob:=OB COPY(Form) |
This will result in:
$date_d:="01/01/2018"
$time_ti:="12:30PM"
$passedData_ob:={"Date" : "01/01/2018" , "Time" : "12:30PM"}