[Scilab-Dev] evaluation of a Scilab expression from java in the current Scilab environment

Martin Hochwallner Martin.Hochwallner at gmx.at
Tue Jul 30 11:08:29 CEST 2013


Hello

I am writing on an application using Scilab and Xcos. Right now I am working on a specialised alternative for “getvalue(..)” (GUI to edit parameters of Xcos blocks) written in Java to support my own blocks.
I need to access the current Scilab workspace (execute an expression and get back the result) from Java -- something like { x = myScilab.getResultFromExpression("2.0*sin(foo)") } with an error message in case of a non-valid expression. Mostly it will be used to access variables defined by an initialisation script. Current means that the java code of interest is run through JIMS and shall access its calling Scilab environment.

Where can I find this functionality?



What I tried:
Javasci:
Used in a separated session it provides roughly the ask functionality. See the example included in Javasci.
Used within an existing Scilab session I run in some problems.

The sci.open() does not return when called from within a Scilab session and is probably not needed as there are static methods like Scilab.getInCurrentScilabSession(..), too.
sci.get(..) is working when I skip sci.open(). Maybe that is the cause for the further problem with sci.execException.


Scilab.getInCurrentScilabSession(“foo”) is working (returning a Scilab variables content)  but I found one strange behaviour:
Scilab.getInCurrentScilabSession(“foo * 2”) returns the value of foo, not 2*foo and not an Exception. This happens also when called as separate session.

When called from within a running Scialb session sci.execException(“X2C_JAVA_ACCESS = 987”)  (or any other valid expression) throws

org.scilab.modules.javasci.JavasciException$ScilabErrorException: A Scilab error occurred: winqueryreg: Cannot query value of this type.
Code: 999

and called one more time:

org.scilab.modules.javasci.JavasciException$ScilabErrorException: A Scilab error occurred: Method invocation: An error occurred during the data retrieving in Java:An exception has been thrown in calling the method getValueFromExpression_1:org.scilab.modules.javasci.JavasciException$ScilabErrorException: A Scilab error occurred: winqueryreg: Cannot query value of this type.Code: 999
Code: 999

In a separate session as in the Javasci example that works.


Do you have any hints where to dig to get something like getResultFromExpression("2.0*sin(foo)") working? Or does this somewhere already exist?

Thanks

Martin



More information about the dev mailing list