The tables in manual section 2.6 (Reflection) note that Java arrays
are converted to Jess multifields, and vice versa. It's not terribly
convenient, and there's no way to do multidimensional arrays, but what
you want is something like this.

        (call ?agent setObserver
                "TestObserver" ;//name of the object to load and in
                "dummyAction"  ;// name of the methode to invoke
                (create$ "one", "two", "more") ;//argumentnames
                (create$ 5 3 5 4))

The last argument might give you trouble, I'm not sure; you might need
to explicitly create each Integer wrapper object in the multifield.

Note that 1) Jess Strings will be automatically converted to Java
strings so you shouldn't have to create java.lang.Strings explicitly,
ans 2) Jess has an (import) function, and java.lang.* is automatically
imported, so you can write (new Integer 1), in any event.

There are pathological cases where it's simply impossible to call a
Java method from Jess; if there are multiple overloaded methods each
taking a different kind of array as an argument, for example, there
may be problems. In these cases, you can always write a Java wrapper
for the method to make it easier to call from Jess.


I think Arend Ligtenberg wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> 
> 
> 
> 
> hi Jess users,
> 
> Perhaps some of you did it a thousand times. But I have trouble doing it:
> I like to send an array to Java using the call function.
> It looks like this:
> 
> ...
> (defrule do_observations
>        ?ph <- (phase observe )
>        (actor_identifier ?ai)
>        (agent (OBJECT ?agent) )
>         ...
>       =>
>       (retract ?ph)
>       (call ?agent setObserver
>               (new java.lang.String "TestObserver") ;//name of the object to load 
>and in
>               (new java.lang.String "dummyAction")  ;// name of the methode to invoke
>               (new java.lang.String[] {"one", "two", "more"}) ;//argumentnames
>               (new java.lang.Integer[] {5 , 3, 5 ,4}) ;//argument values
>       )
> 
> )
> 
> ...
> 
> The above clearly doesn't work. Probably because it isn't the right
> approach. Can someone tell me what's the best approach to construct
> something like this.
> 
> Thanks already a lot in advance
> 
> Regards
> 
> Arend Ligtenberg
> 
> 
> +++++++++++++++++++++++++++++++++++++++++++++
> Wageningen UR
> Centre for Geo-Information
> P.O. Box 47
> 6700 AA Wageningen
> The Netherlands
> tel: +31 317 47 46 53
> fax: +31 317 47 45 67
> email: [EMAIL PROTECTED]
> internet: www.gis.wageningen-ur.nl/cgi
> ++++++++++++++++++++++++++++++++++++++++++++++
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the
> list (use your own address!) List problems? Notify [EMAIL PROTECTED]
> ---------------------------------------------------------------------
> 



---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9012                  [EMAIL PROTECTED]
PO Box 969                  http://herzberg.ca.sandia.gov
Livermore, CA 94550

---------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the
list (use your own address!) List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------

Reply via email to