On Mar 29, 2007, at 6:14 PM, [EMAIL PROTECTED] wrote:
Hi, I've been writing my own userfunctions in Java for Jess and have
managed fine returning strings, integers and doubles to Jess but now I
want to return an array but have come stuck and don't know the
syntax well
enough to know how to do it. Error = "The constructor Value(String
[], int)
is undefined". Once I pass back my Java array of type String to my
Jess
code I will be hoping to iterate through it. Thanks.
------------------------------------------------
public Value call(ValueVector vv, Context c) throws JessException {
String s = vv.get(1).stringValue(c);
int i = vv.get(2).intValue(c);
String list[] = splitMessage(s, i);
return new Value(list, RU.LIST);
}
In Jess 7, one easy way to turn any kind of array into a ValueVector
is to use the static "objectToValue()" method in the jess.RU class.
return RU.objectToValue(String[].class, list);
This will return a Value of type RU.LIST containing a ValueVector of
RU.STRING objects.
in Jess 6, you have to do it yourself;
ValueVector vv = new ValueVector();
for (String s: list)
vv.arg(s);
return new Value(vv, RU.LIST);
---------------------------------------------------------
Ernest Friedman-Hill
Advanced Software Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://www.jessrules.com
--------------------------------------------------------------------
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]
--------------------------------------------------------------------