CALL FORM and return value

you know command EXECUTE METHOD IN SUBFORM ?

It allows to get a value back.

But for CALL FORM ? It is a one way !

What about the possibility to get back a value from CALL FORM ?
From a worker, being then able to get a value from a slider, a field, a variable, a widget… !!!

Does it mean sense ?

I accept of course your way to work but please accept as well that this command was created to run asynchronously.

Get something back: call, wait, wait, wait, use the result
That’s synchronously.

Fine to use, easy to work, but does not allow to use the power of preemptive, of multi core computers.

asynchronously requires a different thinking.
You don’t wait, but you give a callback routine.

Then you pass work to another employee, you don’t wait for him to be finished (and do nothing in that time), you ask him to call back and return the result. So you give a callback number and maybe a case ID (invoice ID, etc)

Same in 4D with Call Form or Call Worker (or EXECUTE ON SERVER)
You pass a call back number. This could the client name, if running on the server.
It can be the worker Name. And a case ID allowing to know what to do with the result.

Very different approach, I know, not unusual these days.

: Olivier GRIMBERT

But for CALL FORM ? It is a one way !

No, does not make sense. I will tell you why:

CALL FORM and CALL WORKER are designed for using in a asynchron environment. That’s why you don’t have any return values. When calling a form or a worker, the benefit is, that the original process is not waiting for a result. It works like a mail box: it just sends a message for doing something.

For your solution:

  • call a worker which does something -> then call the form
  • when the form is called and is ready then you have just to call the worker again

You can do this with objects very well, where you can tell the worker or the form what to do.
The benefit again: you don’t have deadlocks or blocking forms and processes!

Sorry, i was too late. Mr. Maul already answered.

but it is nice to get confirmation :slight_smile:

Yes, I knew that aout preemptive.
I’ll change my mind on how to modify widgets.
You’re right !

Note also you can easily get a return value from CALL FORM and CALL WORKER with low overhead using the New signal command. I think this is preferable in a lot of cases versus a callback model which can be more difficult to understand and debug.