Call method dynamically defined

Is there a way to call a method with method’s name defined by code?

Supposing to call a method called “MyMethod”, is there a way to obtain something like this?

[code]Dim MethodName as String
Dim MethodResult as Boolean

MethodName = “MyMethod”
MethodResult = MethodName()[/code]

Not the way you suggest, but there are two ways to go about this.

  1. Make the method part of a context object for XojoScript and call it using Xojoscript.
  2. In an initialization method, store the method addresses with WeakAddressOf in a dictionary along with the name of the method. You can then call the method using “MethodsDictionary.value(MethodName).invoke()” (where MethodsDictionary is the dictionary of method addresses and MethodName is your string).

Delegates are what you need

Look at Introspection module in the docs.

yes, look at keyword ‘invoke’

Thanks to everybody. I will look them as suggested.