Page 1 of 1

invokeMethod

Posted: Fri Aug 07, 2009 2:54 pm
by ConvertFromOldNGs
by Danny Sheehan >> Fri, 7 Oct 2005 5:05:39 GMT

Hi

Is there any way to execute a method using invokeMethod (or sendMsg) that will update any io parameters you pass it?

Thanks

Danny Sheehan

Re: invokeMethod

Posted: Fri Aug 07, 2009 2:54 pm
by ConvertFromOldNGs
by Patwos >> Thu, 13 Oct 2005 2:56:42 GMT

I presume you're currently using the RootSchema implementation of Object::sendMsgWithParams to pass through the parameters to the method in question. If you look at the implementation of this method you'll notice from the signature that the usage of the paramList parameter is the default, in other words constant. Therefore any changes made to output or io parameters in the method that was called via sendMsgWithParams will not be reflected in the calling method.

The following approach works, but I would be interested in knowing whether or not this is intended to work and will continue to do so in future releases of Jade. (Perhaps someone from Jade would care to confirm or deny this?)

1. Define a new external method on Object at the highest appropriate schema level:

sendMsgWithIOParams( msg : String; paramList : ParamListType io ) : Any is "objSendMsgWithParams" in "jomsupp";

2. Change your method logic to use Object::sendMsgWithIOParams instead of Object::sendMsgWithParams where appropriate.

Hope that helps,
Pat.

Re: invokeMethod

Posted: Fri Aug 07, 2009 2:54 pm
by ConvertFromOldNGs
by Jade Support >> Thu, 13 Oct 2005 22:29:28 GMT

Yes, this will work. However, there are a couple of considerations.

Since the variable parameter list has a single formal definition all actual parameters must be compatible with the declared usage, ie if the parameter list is declared usage IO all parameters passed must be updatable (not constant). The compiler will enforce this, passing a constant will result in a syntax error: "Cannot assign to constant".

The formal parameters of the method being called do not need to be usage IO for this to work, however when the method is called the value will be copied back from the parameter even though it's value has not changed.

Jade Support.

Re: invokeMethod

Posted: Fri Aug 07, 2009 2:54 pm
by ConvertFromOldNGs
by Danny Sheehan >> Thu, 13 Oct 2005 23:39:01 GMT

I suppose what I am really trying to do is implement a callback.

I am trying to get all methods (with varying paramters and return trypes) on a class to be managed by another managing method on the same class so that common pre and post method execution code can be maintained on the managing method.

Is there another way to do this then that supports selective io parameters?