I am trying to proces a yaillist to a mathematic formula. I thought to figering out this and the extension has executed. But in a test app I get an errorcode.
Can anybody help me with this.
The code is:
The errorcode, when I try to write the result tot a label, is this:
Perhaps this will help ?
Thanks for your info. Am going to look at this..
I have tried to use the methods in this tutorial. My app gives a error code that it cannot cast a string to a double. But it isn't a string. I think i have to make the incomming yaillist a double but I don't know how.
You must initialise new double then cast the result into this new double
Catch the bove result into a string then,
String str = above return result;
double result = Double.parseDouble(str);
return result;
Or
String str = above return result;
Double result = new Double(str);
return result;
May be work for you
Tanks for your reply.
I was assuming that the errorcode was rased by this code.
List NwLst = new ArrayList(items);
May be I am wrong. I am a beginning java programmer, I don't know how to use your code for this problem.
Sorry, I ment this code
List NwLst = new ArrayList(items);
"List NwLst = new ArrayList(items);"
How does this works?? it skips Double between arrows
You should be calling Double.parseDouble()
before you do call the Math.log10() method.
The line should probably be like:
Math.log10(Double.parseDouble(*your item*.toString()))
Thanks!! Ill try this.
I have done what you advised and the extension was created. So far so good. But when I use the extension in my app the same error code persists.
This is the reason why I think the errorcode is rased from a line before this.
ah yes, check the list function, you have declared List<Double>
and passing a non-double list (Yail List) and thus resulting in the problem
Indeed, how can I pass a double list. How do I do that?
you would need to parse all the doubles as string from the list,
thats how it should be:
@SimpleFunction
public int TestDoubles(YailList values) {
List<Double> doubles = new ArrayList<>();
for (String val : values.toStringArray()) {
// parsed double
double d = Double.parseDouble(val);
doubles.add(d);
}
// and now you have the double list
return doubles.size();
}
Its works!!!!
Like you wrote, exactly.
Thank you very very much. Now I can go on.....
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.