Page 1 of 1

Calling a Jade method from a 'Method' object

Posted: Tue Jul 03, 2012 11:38 am
by rolly
I have reason to call a jade method on an object when all I have is the name of a method in a string form (I am using Jade 6.3)

Now I know I can get a reference to a Method object by doing a 'method := object.class.getMethodInHTree("methodName");
And I know I can also use the Async Method framework to call a method I know the name of, but the framework seems to be overkill for what I need.
So is a way for me to call the method directly?
As an aside, I am struggling to find info about the 'Method' object in the Jade documention too, so is it there but I am just missing it, or is not there?

Thanks
Roland

Re: Calling a Jade method from a 'Method' object

Posted: Tue Jul 03, 2012 12:00 pm
by torrie
Take a look at the "sendMsg" method (defined on Object.) This (and the sendMsgWithParams, sendMsgWithIOParams) methods allow you to call any method on an object. For example:

Code: Select all

Customer.firstInstance.sendMsg( "recalculateBalance" );

Re: Calling a Jade method from a 'Method' object

Posted: Tue Jul 03, 2012 12:42 pm
by rolly
Thanks Torrie, this was part of what I needed, and now you reminded me, the deep recesses of my mind tell me I did actually know this.
Now any ideas how I can derive information about method parameters from schema metadata or Method object?

Re: Calling a Jade method from a 'Method' object

Posted: Tue Jul 03, 2012 1:10 pm
by torrie
Method parameters are hidden in Jade. The following script will list a method's parameters in order. Should get you started for calling a method.

Code: Select all

vars oClass : Class; oMethod : Method; oParam : Parameter; begin oClass := currentSchema.getClass( VCContact.name ); oMethod := oClass.getMethod( VCContact::update.name ); foreach oParam in oMethod.getPropertyValue("parameters").ParameterColl do write oParam.name & Tab & oParam.type.name; endforeach;