First, thanks to you for coding a workarround solution and share it with us in forum,
sharing and discussing our thinking and coding helps us all always (direct or indirect, immediatly or later).
(Hi to all…)
Disscusing about missing objectGetPointer(Form.myobj)
(and objectGetDataSource, objectSetDataSource with Form.myobj
is not new in 4DForum. Other ForumMembers did this as long as Form.myobj
Feature exist and i did this too.
Take a look at my old post, yes its too with “FORM Convert to dynamic”,
because it was the only way to fetch these kinds of datasource.
(sorry i have three forum accounts, and i ask 4D to put all posts in my new account what are created from 4DForumAdmin).
Alternatives are, let datasource empty then 4D auto create a dynFormVariable
which can fetched with objectGetPointer (returns a pointer to dynFormVariable).
But this is not a solution for all, because most of time you need Form.myCollection
and This.myCollectionColumn or to adress any other subItems…
Remember for objectGetPointer, pointers can only point to a variable, field or table.
Dot-Notation “Form.myA” or “$obj.myA” is not a variable, it is a expression
and you can not have a pointer to a expression!
Datasource can always be a expression like “Form.collectionA”
or any other expression for example “Current time”.
With objectSetValue($objName) you can not set the value for those expression
but you can always do a objectGetValue($objName).
So objectSetValue is a little bit difficult to done in a generic/dynamic coding routine.
Not all datasource-definitions are containers which can receive/store a value.
When 4D create new command objectSetValue,
then 4D internaly must check "is expression value-set-able (this is not easy to detect).
I did not know 4D can solve this…
What 4D easier can do is to give objectGetDataSource a new option
to return its result as text or as pointer. So as text you can get any datasource-expression
and detecting with own code is-this-datasource-value-set-able.
Maybe 4D found a way to generate auto dynFormVariables (like when datasource empty)
for all datasource-definitions which syntax is like “Form.myA.myX”
and for syntax like “This.myX”.
// OBJECT Get pointer() give as result a pointer back.
// Pointer can only point to a variable, field or table!
// To Point to a expression or anything else is not possible.
// error can not be done
$ptr:=->Form // ptr to a command/expression not possible
$ptr:=->Form.myA // ptr to a expression not possible
$ptr:=->$obj.myA // ptr to a expression not possible
// ok, can be done
$ptr:=->$obj // ptr to variable $obj which is a representation of the form-object