Add save and load commands (PrefStorage)
This commit is contained in:
parent
acc44f0765
commit
9e6d4e4230
@ -63,6 +63,7 @@ import java.util.Iterator;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.prefs.Preferences;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import static net.apocalypselabs.symat.Main.API_URL;
|
import static net.apocalypselabs.symat.Main.API_URL;
|
||||||
import org.matheclipse.core.eval.EvalUtilities;
|
import org.matheclipse.core.eval.EvalUtilities;
|
||||||
@ -762,56 +763,20 @@ public class Functions {
|
|||||||
return FileUtils.MD5(data);
|
return FileUtils.MD5(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Make globals work!
|
public void save(String key, String val) {
|
||||||
// /*
|
Preferences prefs = Preferences.userNodeForPackage(Functions.class);
|
||||||
// Global variables are accessible across scripts.
|
prefs.put(key, val);
|
||||||
// */
|
try {
|
||||||
// /**
|
prefs.flush();
|
||||||
// * Set a global variable.
|
} catch (Exception ex) {
|
||||||
// *
|
|
||||||
// * @param name The variable name
|
}
|
||||||
// * @param var The variable
|
}
|
||||||
// */
|
|
||||||
// public static void global(String name, Object var) {
|
public String load(String key) {
|
||||||
// GLOBALS.put(name, var);
|
Preferences prefs = Preferences.userNodeForPackage(Functions.class);
|
||||||
// }
|
return prefs.get(key, "");
|
||||||
//
|
}
|
||||||
// /**
|
|
||||||
// * Get a global variable.
|
|
||||||
// *
|
|
||||||
// * @param name The variable name
|
|
||||||
// * @return The variable
|
|
||||||
// */
|
|
||||||
// public static Object global(String name) {
|
|
||||||
// Object item = GLOBALS.get(name);
|
|
||||||
// return item;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Fix for Python reserved word "global"
|
|
||||||
// public static void setglobal(String name, Object var) {
|
|
||||||
// global(name, var);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Fix for Python reserved word "global"
|
|
||||||
// public static void getglobal(String name) {
|
|
||||||
// global(name);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Clear all the GLOBALS.
|
|
||||||
// */
|
|
||||||
// public static void clrglobals() {
|
|
||||||
// GLOBALS.clear();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Check if the given global key is set.
|
|
||||||
// * @param name The key to check.
|
|
||||||
// * @return True if the key exists, else false.
|
|
||||||
// */
|
|
||||||
// public static boolean globalcontains(String name) {
|
|
||||||
// return GLOBALS.containsKey(name);
|
|
||||||
// }
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Other
|
Other
|
||||||
|
Loading…
x
Reference in New Issue
Block a user