Subform 'Variable or Expression' (Bound variable) not working with it is a Form.variable

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Subform 'Variable or Expression' (Bound variable) not working with it is a Form.variable

4D Tech mailing list
On parent form  WIDGET_TESTER   I  have a subform  of instance name  ‘formDate’.  The name of the subform is  “DateEntry”.
I wish to have a BOUND VARIABLE of type DATE on this instance.

if the DATE is a process variable, it works swell.
**** if it is based on the parent form’s FORM.   (such as Form.thisDate)  this does not work.    ***** — MY CONUNDRUM!

in particular:
In the Subform’s form method, in the  ‘On Bound Variable Change’ handler, the subform needs to get the bound variable’s pointer.
This is done either with  OBJECT Get Pointer(Object subform container)
or (as in 4D’s widget collection source code)   Self(Object subform container) is used.

This is successful if the bound variable is a process variable. It does not work if it is   Form.thisDate (which is a date; set to ‘current date’ for example).

The Form.thisDate is defined in the parent’s ON LOAD handler, so it should exist by the time the instance ‘formDate’ is configured. Sure seems to work for process variables!

I am not yet an expert on subform creation, as I have mostly avoided them in the past.
However, I can see the wisdom of creating widgets to put in my own object library.
But they need to be able to work in the context of a parent’s Form. object to be of use for me, as I use this extensively rather than process variables.

thanks for any suggestions,
Chris Belanger

——————

Detailed explanation (if needed or interested)


I’ve been working on making some widgets, inspired by 4D’s collection. My question is about rewriting the DateEntry widget. After I do that, I intend to do some other widgets.

When I looked at the 4D source code, I saw it still uses a lot of code, methods, process vars, etc.
So I made a ‘DateEntry’ widget (in my custom component) that employs Form. objects / variables instead. It works very nicely, with a great simplification of code and elimination of process methods and process vars.

When the widget is put (as a subform) on a Parent Form, the Bound Variable is of type DATE.
It works as expected whenever it is a PROCESS VARIABLE.

However, if the bound variable is    Form.theDate  (a DATE ‘variable’), then it fails.


WHAT I AM DOING:
In the widget’s form:
In the FORM EVENT ‘On Bound Variable Change’ — I configure what I need for the widget to process the bound variable. This involves creating some Form. vars to manage the input.
• so in this situation, it is very simple.

Case of
:(Form event = On Bound Variable Change)  // use the value of the Bound Variable (a Date) to configure the components DAY, MONTH, YEAR

$theVarPtr:=OBJECT Get Pointer (Object subform container)  // this is the pointer to the bound variable, for instance    ->processVar
Form.theDate := $theVarPtr->   // copy the contents of the subform contain to our widget’s ‘date’ so we can manipulate it without changing the bound variable until we are ready (On Deactivate)
// Break it into its component pieces: DAY, MONTH, YEAR, for the widget
Form.theDay := Day of(Form.theDate)
Form.theMonth:= Month of(Form.theDate)
Form.theYear:=Year of(Form.theDate)


——

OBJECT Get Pointer ( Object subform container) works as expected when the Parent Form’s bound variable is of type DATE and is a process Variable.

 Self(Object subform container) also gets the Parent Form’s bound variable  (this is what the 4D widget uses; however,   Self  is always Nil in this situation)

** however **
it does not work when the bound variable is a Date that is define in the Parent’s   Form. context.  I.E.  if the bound variable is   Form.simpleDate  this does not work.
If it is  Form.entity.simpleDate   this also does not work.


**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Subform 'Variable or Expression' (Bound variable) not working with it is a Form.variable

4D Tech mailing list
Actually, I see that 4D’s widgets do not work either (dateEntry) when the bound variable is    Form.thisDate.

I know that 4D cannot make Pointers to Form. elements like that.
But it is pretty bad that there is no way (apparently) for a subform to access its bound variable in this instance.

anyone confirm that?

— Chris



> On Jul 7, 2019, at 6:34 PM, Chris Belanger <[hidden email]> wrote:
>
> On parent form  WIDGET_TESTER   I  have a subform  of instance name  ‘formDate’.  The name of the subform is  “DateEntry”.
> I wish to have a BOUND VARIABLE of type DATE on this instance.
>
> if the DATE is a process variable, it works swell.
> **** if it is based on the parent form’s FORM.   (such as Form.thisDate)  this does not work.    ***** — MY CONUNDRUM!
>
> in particular:
> In the Subform’s form method, in the  ‘On Bound Variable Change’ handler, the subform needs to get the bound variable’s pointer.
> This is done either with  OBJECT Get Pointer(Object subform container)
> or (as in 4D’s widget collection source code)   Self(Object subform container) is used.
>
> This is successful if the bound variable is a process variable. It does not work if it is   Form.thisDate (which is a date; set to ‘current date’ for example).
>
> The Form.thisDate is defined in the parent’s ON LOAD handler, so it should exist by the time the instance ‘formDate’ is configured. Sure seems to work for process variables!
>
> I am not yet an expert on subform creation, as I have mostly avoided them in the past.
> However, I can see the wisdom of creating widgets to put in my own object library.
> But they need to be able to work in the context of a parent’s Form. object to be of use for me, as I use this extensively rather than process variables.
>
> thanks for any suggestions,
> Chris Belanger
>
> ——————
>
> Detailed explanation (if needed or interested)
>
>
> I’ve been working on making some widgets, inspired by 4D’s collection. My question is about rewriting the DateEntry widget. After I do that, I intend to do some other widgets.
>
> When I looked at the 4D source code, I saw it still uses a lot of code, methods, process vars, etc.
> So I made a ‘DateEntry’ widget (in my custom component) that employs Form. objects / variables instead. It works very nicely, with a great simplification of code and elimination of process methods and process vars.
>
> When the widget is put (as a subform) on a Parent Form, the Bound Variable is of type DATE.
> It works as expected whenever it is a PROCESS VARIABLE.
>
> However, if the bound variable is    Form.theDate  (a DATE ‘variable’), then it fails.
>
>
> WHAT I AM DOING:
> In the widget’s form:
> In the FORM EVENT ‘On Bound Variable Change’ — I configure what I need for the widget to process the bound variable. This involves creating some Form. vars to manage the input.
> • so in this situation, it is very simple.
>
> Case of
> :(Form event = On Bound Variable Change)  // use the value of the Bound Variable (a Date) to configure the components DAY, MONTH, YEAR
>
> $theVarPtr:=OBJECT Get Pointer (Object subform container)  // this is the pointer to the bound variable, for instance    ->processVar
> Form.theDate := $theVarPtr->   // copy the contents of the subform contain to our widget’s ‘date’ so we can manipulate it without changing the bound variable until we are ready (On Deactivate)
> // Break it into its component pieces: DAY, MONTH, YEAR, for the widget
> Form.theDay := Day of(Form.theDate)
> Form.theMonth:= Month of(Form.theDate)
> Form.theYear:=Year of(Form.theDate)
>
>
> ——
>
> OBJECT Get Pointer ( Object subform container) works as expected when the Parent Form’s bound variable is of type DATE and is a process Variable.
>
> Self(Object subform container) also gets the Parent Form’s bound variable  (this is what the 4D widget uses; however,   Self  is always Nil in this situation)
>
> ** however **
> it does not work when the bound variable is a Date that is define in the Parent’s   Form. context.  I.E.  if the bound variable is   Form.simpleDate  this does not work.
> If it is  Form.entity.simpleDate   this also does not work.
>
>

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Subform 'Variable or Expression' (Bound variable) not working with it is a Form.variable

4D Tech mailing list
that is correct...

an object property is not a variable, so it doesn't qualify as a bound variable.

and a pointer can only point to a table, field, variable, array or array element,
so again, an object property is out of luck.

the widget system works best when the expression or variable is blank.

> 2019/07/08 9:59、Chris Belanger via 4D_Tech <[hidden email]>のメール:
>
> Actually, I see that 4D’s widgets do not work either (dateEntry) when the bound variable is    Form.thisDate.
>
> I know that 4D cannot make Pointers to Form. elements like that.
> But it is pretty bad that there is no way (apparently) for a subform to access its bound variable in this instance.
>
> anyone confirm that?




**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: Subform 'Variable or Expression' (Bound variable) not working with it is a Form.variable

4D Tech mailing list
okay, that’s the scoop. Thank you for confirming.

So I was thinking of storing the path to the attribute I need to manage INTO the widget.
I see I can do that simply enough, inside the SCRIPT for the CONTAINER.
I just put this into the script for the container (and enabled the ‘on load’ event for it).
: (Form event=On Load)
                EXECUTE METHOD IN SUBFORM(OBJECT Get Name;"SET_FORM_OBJ_ATTR";*;"myEntity.formDate”)

SET_FORM_OBJ_ATTR( ) merely assigns it to  Form.sourceAttrPath  in the widget.

This works okay.


I am trying to figure out how to trigger a CUSTOM EVENT in the subform. I will name it on_WidgetUpdate  (constant) -93
If I can trigger this custom event as needed, then the widgets can update themselves by looking at the  Form.sourceAttrPath to figure out where to update from.

I am not clear on how I would trigger the event, though. Hopefully it can be done in a ‘form-level’ way so that all the subforms (i.e. widgets) would receive it automatically. But I could send it to each one if need be.

If you can tell me what I do, I would appreciate that (to trigger the custom event).

I’m thinking I may have to use CALL SUBFORM CONTAINER ( on_WidgetUpdate ) and then that container object will have to execute within the subform (EXECUTE METHOD IN SUBFORM)

— Chris




> On Jul 7, 2019, at 9:18 PM, Keisuke Miyako via 4D_Tech <[hidden email]> wrote:
>
> that is correct...
>
> an object property is not a variable, so it doesn't qualify as a bound variable.
>
> and a pointer can only point to a table, field, variable, array or array element,
> so again, an object property is out of luck.
>
> the widget system works best when the expression or variable is blank.
>
>> 2019/07/08 9:59、Chris Belanger via 4D_Tech <[hidden email]>のメール:
>>
>> Actually, I see that 4D’s widgets do not work either (dateEntry) when the bound variable is    Form.thisDate.
>>
>> I know that 4D cannot make Pointers to Form. elements like that.
>> But it is pretty bad that there is no way (apparently) for a subform to access its bound variable in this instance.
>>
>> anyone confirm that?
>
>
>
>
> **********************************************************************
> 4D Internet Users Group (4D iNUG)
> Archive:  http://lists.4d.com/archives.html
> Options: https://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:[hidden email]
> **********************************************************************

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[hidden email]
**********************************************************************