[Mathlib-commitlog] SF.net SVN: mathlib:[623] JMathLib/trunk/src/jmathlib/toolbox/general/clear .ja
Status: Beta
Brought to you by:
st_mueller
|
From: <st_...@us...> - 2009-01-05 15:10:30
|
Revision: 623
http://mathlib.svn.sourceforge.net/mathlib/?rev=623&view=rev
Author: st_mueller
Date: 2009-01-05 15:10:21 +0000 (Mon, 05 Jan 2009)
Log Message:
-----------
changed handling of global variables
Modified Paths:
--------------
JMathLib/trunk/src/jmathlib/toolbox/general/clear.java
Modified: JMathLib/trunk/src/jmathlib/toolbox/general/clear.java
===================================================================
--- JMathLib/trunk/src/jmathlib/toolbox/general/clear.java 2009-01-05 15:08:24 UTC (rev 622)
+++ JMathLib/trunk/src/jmathlib/toolbox/general/clear.java 2009-01-05 15:10:21 UTC (rev 623)
@@ -19,6 +19,7 @@
if (getNArgIn(operands) != 1)
throwMathLibException("clear: number of arguments < 1");
+ // get subcommand or variable name
if (operands[0] instanceof VariableToken)
{
s = ((VariableToken)operands[0]).getName();
@@ -29,18 +30,44 @@
s = ((CharToken)operands[0]).getValue();
}
- if (!s.equals(" "))
+ // check what the user wans to clear
+ if (s.equals("variables"))
{
- // remove one variable
- getVariables().remove(s);
+ // only clear local variables
+ getLocalVariables().clear();
}
- else
+ else if (s.equals("globals"))
{
- getVariables().clear();
+ // clear global variables
getGlobalVariables().clear();
+ getLocalVariables().clear();
+ //TODO: when removing global variables also remove
+ // pointers from local to global varaibles in "getLocalVariables"
+ }
+ else if (s.equals("functions"))
+ {
+ // clear cache for m-files, class-files, script-files
getFunctionManager().clear();
}
+ else if (s.equals("all"))
+ {
+ // clear everything
+ getLocalVariables().clear();
+ getGlobalVariables().clear();
+ getFunctionManager().clear();
+ }
+ else if (!s.equals(" "))
+ {
+ // remove one variable from local workspace
+ getLocalVariables().remove(s);
+ }
+ else
+ {
+ // clear without any arguments only clears the local workspace
+ getLocalVariables().clear();
+ }
+
return null;
}
}
@@ -52,6 +79,11 @@
clear(variable)
@DOC
Clears the specified variable or, if blank, clears all variables.
+clear()clears local variables
+clear("variables") clears local variables
+clear("globals") clears global variables
+clear("functions"" clear function cache
+clear("all") clear local variables, global variables and function cache
@EXAMPLE
<programlisting>
clear('x');
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|