Form object pointer return Nil

If I set Form.myVar to a form object and if I try to get a pointer from this form object like :

<code 4D>
C_POINTER($myVar_fo_ptr)
$myVar_fo_ptr:=OBJECT Get pointer(Object named;“myVar_fo”)

Form.myVar:=Form.myVar
</code 4D>

myVar_fo_ptr return Nil !

If I set myVar to the same form object, my pointer return a valid pointer.

Why ?

: Maurice INZIRILLO

Why ?

I got the same problem. The solution for me was to work directly with the data: Form[OBJECT Get name]

Thanks for the turn around but it’s not a good solution for me. I need to have both way to address a variable form object.

It seems like a bug for me.

No finally it’s not a bug. but an inconvenience.

Actually Form.xxx is an expression. You can’t put a pointer to an expression

in my case I will solve my issue by using :

<code 4D>
$form:=Form
$ptr:=->$Form
</code 4D>

or

<code 4D>
OBJECT Get name(Object current)
</code 4D>

it is not a bug.

a pointer can only point to

table
field
process variable, array element
interprocess variable, array, array element

there is not concept of pointing to an expression
or a local variable
or an object property
or a collection element.

one must make a decision: use pointers and variables,
or use Form and don’t use pointers.

don’t put new wine in old skin bottle.

p.s. of course you can have point to a local variable if you don’t use Get pointer,
or a form local variable if you use OBJECT Get pointer.

but the main point stands,
using expressions (and object properties fall into this category) as data source
means you can’t depend on pointers any more.

as a general, one should not try to reengineer existing UI using ORDA.

it will ultimately fail.

one should normally consider ORDA for new development (be it in existing application).

Question : How to modify programmatically attributes of a form object if a Form variable is assigned to it ?

: Maurice INZIRILLO

How to modify programmatically attributes of a form object if a Form
variable is assigned to it ?

depends. If it is a form interface attribute, like visible (group objects forms, https://doc.4d.com/4Dv17/4D/17.1/Objects-Forms.201-4178092.en.html), use the object name.

The object name should be used in any case, as this is the only way to use the same data source for several GUI elements.

It you want to change the value, use dot notation.

It’s Ok using the name of the object that I can retrieve using OBJECT
Get Name

: Thomas MAUL

It you want to change the value, use dot notation.

In my case, I don’t know the Form object variable assign to the object form and I need to modify the value of this form object.

So far I can only ask the user to not affect a Form object variable to his object form so I can set the value using a pointer. There’s no other enforcement possible ?

Form is an expression (like 5 * 3), so you cannot have a pointer on that.
Would not help anyway, as (I think) you don’t know the attribute name behind form, like Form.mydata. What you would want to know is “mydata”, the name of the attribute.

I have honestly no clear vision if that would be a clever solution, but you could poste a feature request to have an option for Object Get data source to return the source as string and not as pointer, to make it possible to parse that…

In between you could solve it if you can (and want) to follow rules (set by yourself).
A rule like form attribute name needs to be identical to object name.
Then you could use Form[OBJECT Get Name(…)]

Another way would be to export the form as object (given you know the name of the form).
In the json form you can find your own object and learn the name:
“dataSource”: “Form:C1466.mydata”,

: Thomas MAUL

I have honestly no clear vision if that would be a clever solution,
but you could poste a feature request to have an option for Object
Get data source to return the source as string and not as pointer, to
make it possible to parse that…

I have the same opinion! I cannot imagine any use-case for this.
But indeed, 4D could implement a OBJECT Get Formula and returns the current Formula-Object!
Then i can introspect the formula or convert it to string (formula.toString())

Here is an old discussion about https://forums.4d.com/Post/FR/25467720/0/0/this> (sorry in French)

: Maurice INZIRILLO

So far I can only ask the user to not affect a Form object variable
to his object form

from this line I am going to guess that you want to design a generic component, where you do not know what the “user” (=a 4D developer) will assign as the variable or expression to the object.

this is an atypical context, which is why I feel there is a difference in temperature between those of us who don’t see the need to know the expression (Form.whatever) by code, because normally we already know what is defined in the property list, and we do not use OBJECT SET DATA SOURCE to change it on the fly, or insist on excessively generic code; we just make sure the expression used in the object method matches the expression defined in the property list, and everything works fine.

in theory, I guess you could call Form convert to dynamic and read the https://doc.4d.com/4Dv17/4D/17.1/Dynamic-Forms.300-4201272.en.html#3692346Data Source>. you will get “A 4D variable, field name, or an arbitrary complex language expression”

but then, if this is a widget, it may not work anyway, even if you did know the expression (Form.whatever) if its feature depended on the On Bound Variable Change form event which only works for variables.

widgets that require this form even should not allow “Form.whatever” as its data source.

Here is also another https://forums.4d.com/Post/FR/25691952/0/0/link> with a Time variable :frowning:

it looks like time is going to be supported for object properties soon (ACI0099578) maybe 17R6

no more need for workaround like this:

https://forums.4d.com/4DBB_Main/x_User/298210/files/29763739.zip

What is strange is the fact that Form.mydata affected to a Form Object reacts like a variable because it accept input value but reacts as an expression returning Nil as a pointer if you try to get a pointer from this Form Object.

Object get data source returning a string can solve my issue, here.

I will post this request as a feature

Thanks Thomas.