invokeMethod

Forums for specific tips, techniques and example code
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

invokeMethod

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:54 pm

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

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: invokeMethod

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:54 pm

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.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: invokeMethod

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:54 pm

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.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: invokeMethod

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:54 pm

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?


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 18 guests