What about a method "exec in server" with pointer params?

I did something which works, but I need to be sure, in order to know what append internally ?

ARRAY TEXT** ($T_labels;0)
zzzz_execOnServer (->$counter;->$T_labels)
// Result here are ok ! It works. But how ?

And method “zzzz_execOnServer” has the flag “exec on server”.
Here is an example:

$ptr_counter:= $1
$ptr_T_labels:= $2
For ($i;1;1000)
APPEND TO ARRAY** ($ptr_counter->;“Text”+ String ($i))
End for**

I know I can send back a blog or an object, but this kind of code is the way I like, so I ask me about performances…

When the transferts between 4D server and 4D client occur ?
Is it at the end of the server method, or in each for loop ?

Is it a good way to write code ?

It works quite perfectly. When parameters of an EoS method are references (pointer / object / collection) I suppose 4D uses back and forth blobs or json.

I said “quite” above because I’ve noticed 2 limitations:
• with pointers, any parameter can be used ($0, $1, $2, etc) in/out. But one level max is possible, the EoS method is unable to resolve pointer on pointer. For example $1 array of pointers, each item pointing a child array: on server side children arrays are Nil.
• you can send objects or collections as $1, $2, etc. but you can’t get them back modified by server, while a “normal” method can do that. You have to use $0. I hope this limitation is a youthful defect…

Now about performances, if the parameters are huge (big array / object / collection…) you may try to make it a little better using compressed blob as a vehicle, but keep in mind you make the code harder to maintain this way. I’ve used that with an object recently

Thanks Arnaud.

Don’t expect too much about objects and collections, as I think a copy is made during transfer like for worker or new process parameters, that’s why if you modify them, you wont get them back from server.
This is not an issue as you can collect the object back with $0…
I can’t do that with plenty of arrays (5, 10,…)

Hi Olivier;

There is a method to retrieve the result of an object, after performing the processing you want, you use the JSON Stringify command the result will be a text, at the client level you make a parse.