Asynch method calls

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Asynch method calls

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:40 am

by Lukas Hazlehurst >> Sun, 28 Feb 1999 3:12:30 GMT

I am working on some asynchronous method calls which use a similiar method callback technique to the TcpIpConnection asynch calls, that is, you provide an object and the name of a method and that method on that object will be called when the action is complete.

So far i have been using the sendMsg method of the Object class to call a method by its name. This is fine, my question is, how do you pass parameters into the method when using the sendMsg method ?

Any help appreciated,
Lukas.

(ps, apologise for the blank message previously)

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

Re: Asynch method calls

Postby ConvertFromOldNGs » Fri Aug 07, 2009 11:40 am

by Krull McSkull >> Sun, 28 Feb 1999 20:24:37 GMT

Hi Lukas,
So far i have been using the sendMsg method of the Object class to call a method by its name. This is fine, my question is, how do you pass parameters into the method when using the sendMsg method ?

The Object::sendMsg method doesn't handle parameters. However, there is a method in the JADE external method support library (jomsup.dll) called sendMsgWithParams, which is designed to handle a dynamic list of parameters and an optional return value. There are no external methods defined in RootSchema that use this because you need to define a separate method for each method signature you want to call. For example:

sendMsg1(msg : String; number : Integer) is sendMsgWithParams in jomsupp;
sendMsg2(msg : String; object : Object) is sendMsgWithParams in jomsupp;
sendMsg3(msg : String; param1 : Integer; param2 : Object) : Boolean is sendMsgWithParams in jomsupp;

A small 'trick' is required to define these methods due to a restriction in the JADE development environment. The development environment does not allow you to select or use libraries such as jomsupp that are defined in RootSchema in user sub-schemas. The JADE compiler does not have this restriction. The following steps will allow you to work around the JADE restriction:

1. If you don't have any libraries defined in your sub-schema, add a library, 'dummy' say to your schema from the Browse menu, select Libraries, then Library|Add Library.

2. Add your external method using library 'dummy', it should look something like this:

sendMsgx() is sendMsgWithParams in dummy;

2. Modify your external method definition to take the parameters you require and change the library name from 'dummy' to 'jomsupp' and recompile:
sendMsg3(msg : String; param1 : Integer; param2 : Object) : Boolean is sendMsgWithParams in jomsupp;


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 36 guests