[Mathlib-commitlog] mathlib/Source/MathLib/Functions/IO savevariables.java, NONE, 1.1 loadvariables
Status: Beta
Brought to you by:
st_mueller
|
From: Stefan M. <st_...@us...> - 2007-01-05 17:18:22
|
Update of /cvsroot/mathlib/mathlib/Source/MathLib/Functions/IO In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv3046/Source/MathLib/Functions/IO Added Files: savevariables.java loadvariables.java Log Message: moved loading and saving of variable into to external functions. Variables are not loaded/saved automotically at the start of JMathLib any more. --- NEW FILE: loadvariables.java --- package MathLib.Functions.IO; import MathLib.Tokens.*; import MathLib.Functions.ExternalFunction; import java.io.*; public class loadvariables extends ExternalFunction { public OperandToken evaluate(Token[] operands) { if (getNArgIn(operands) > 1) throwMathLibException("loadvariables: number of arguments > 1"); String file = "." + File.separator + "variables.mlf"; if (getNArgIn(operands) == 1) { if (!(operands[0] instanceof CharToken)) throwMathLibException("loadvariables: argument must be a string"); file = ((CharToken)operands[0]).toString(); } getVariables().loadVariables(file); return null; } // end eval } /* @GROUP IO @SYNTAX loadvariables() loadvariables("name.mlf") @DOC loads the variables from a serialized .mlf-file @EXAMPLES <programlisting> loadvariables() </programlisting> @NOTES The variables are written as a serialized stream of java objects. Therefor the format of the .mlf-file is java-specific. The file is also specific to the versions of MathLib token and classes. @SEE savevariables */ --- NEW FILE: savevariables.java --- package MathLib.Functions.IO; import MathLib.Tokens.*; import MathLib.Functions.ExternalFunction; import java.io.*; public class savevariables extends ExternalFunction { public OperandToken evaluate(Token[] operands) { if (getNArgIn(operands) > 1) throwMathLibException("savevariables: number of arguments > 1"); String file = "." + File.separator + "variables.mlf"; if (getNArgIn(operands) == 1) { if (!(operands[0] instanceof CharToken)) throwMathLibException("savevariables: argument must be a string"); file = ((CharToken)operands[0]).toString(); } getVariables().saveVariables(file); return null; } // end eval } /* @GROUP IO @SYNTAX savevariables() savevariables("name.mlf") @DOC saves the variables from the current workspace into a serialized .mlf-file @EXAMPLES <programlisting> savevariables() </programlisting> @NOTES The variables are written as a serialized stream of java objects. Therefor the format of the .mlf-file is java-specific. The file is also specific to the versions of MathLib token and classes. @SEE loadvariables */ |