This class provides the basic methods to execute Scilab code and scripts. Deprecated: Please use Javasci v2
This class is static. Since the Scilab environnement is persistant, all variables will remain accessible with the Java application.
Method Summary :
public static void
Events() - Execute a Scilab event
public static boolean
HaveAGraph() -Check if there is any scilab
graphic window open (return True if it is the case).
public static boolean Exec(String
job) - Execute a job in scilab. return true if
there is no error.
Note that the given expression must be consistent by itself. Then, a serie of Exec defining a function will not work. Please consider calling it with a single string instruction or using a temporary file with the method ExecuteScilabScript.
For example: Scilab.Exec("function foo(); disp('bar'); endfunction"); will work when Scilab.Exec("function foo();"); Scilab.Exec("disp('bar');"); Scilab.Exec("endfunction;"); will not work since each statement being processed independently
public static native boolean ExistVar(String
VarName)- Detect if VarName exists in Scilab.
return true if Varname exist.
public static native int TypeVar(String
VarName) - Return Scilab type of VarName. See
type
public static native int
GetLastErrorCode() - Return last Error code. See
lasterror
public static boolean
ExecuteScilabScript(String scilabscriptfilename)- Execute a scilab script (.sce) return true if
there is no error.
public static native boolean
Finish() - Terminate scilab (call scilab.quit ,
close a scilab object)
// A Scilab / Java example // Filename: ScilabExample.java import javasci.Scilab; public class ScilabExample { public static void main(String []args){ String myVar="myVariable"; Scilab.Exec(myVar+"=(%pi^4)/90;disp(myVariable);"); // Simple display if (Scilab.ExistVar(myVar)) { System.out.println("Variable "+myVar+" exists. Type: "+Scilab.TypeVar(myVar)); } if (!Scilab.Exec("disp(plop);")) { // Error System.err.println("Last error: "+Scilab.GetLastErrorCode()); // Error } Scilab.Finish(); } }
A.C