Starting with 4D v19 R5, the ability to associate a variable with a subform has enriched the possibilities of interfaces and communication between forms and subforms. The means of communication are now simplified by two new commands: Say hello to OBJECT Get subform container value and OBJECT SET SUBFORM CONTAINER VALUE.
Two new commands
The new commands OBJECT Get subform container value and OBJECT SET SUBFORM CONTAINER VALUE must be used in the context of the subform.
The first one – OBJECT Get subform container value will most often be used when an On Bound Variable Change event is generated, i.e., after the variable (or the expression) associated with the subform of the parent form is modified. It is therefore used to read this new value.
The second one – OBJECT SET SUBFORM CONTAINER VALUE will be used if, from the subform, you wish to modify the value of the variable (or expression) associated with the subform in the parent form.
Why these commands?
Until now, there were two ways of obtaining this information.
The simplest (and most recent) way is to associate a variable of type object with the subform. In this case, the attributes of this object are accessible directly by the Form function within the subform. This works fine but using an object when you need a simple value is not necessarily a good practice.
The second way (more historical) is to create a pointer to the variable in question via the OBJECT Get pointer command with the Object subform container parameter. This works, but only when a variable is associated with subforms. Unfortunately, this is not possible when it is an expression (e.g., Form.myValue) because it is not possible to create a pointer to an expression.
So, these two commands represent the most convenient and straightforward solution for simple cases! It will simplify the programming of the most common cases. The code will be more readable and easier to maintain.
Enjoy programming with 4D!