I need to simulate assigning a procedure to a variable in order to be able to call it through the variable

I need to simulate assigning a procedure to a variable in order to be able to call it through the variable.

How could I do that, is it possible?

In other languages ​​this would be a function type variable to dynamically link calls to subroutines.

Any suggestion,
Osmany

See

http://www.appinventor.org/bookChapters/chapter21.pdf

from

http://www.appinventor.org/book2

Nothing there, just static calls to procedures from procedures drawer.

You really have to jump through hoops to attempt such a thing in AI2.

You could assign different Clock components to variables, and enable their Timers using generic blocks. But the Clocks would need to communicate through global variables or other side effects.

Or you would have to code your own interpreter for data representations of the calls, stack and all.

Some people run JavaScript for various stunts.

I figured that, but I had to ask.
What I really need is to invert dependency in my code. Something like passing dynamic linked procedure by parameter.

Something similar to "Any component" drawer, but for procedures.

Thanks any way.

In fact there is a PR for anonymous procedure

but MIT have no plan to merge it. :smiling_face_with_tear:

What kind of app needs such a thing?

When you want to organize your code following the dependency injection design pattern.

A simple solution would be to provide the possibility of defining and implementing interfaces (set of procedures). Then you only have would to instantiate the desired implementation and pass it as a parameter.

This would require AI2 to provide object oriented programming.