Disable globals, too buggy for next release

master
skylarmt 9 years ago
parent 2fc829d2af
commit 5a57ff09e8

@ -219,55 +219,57 @@ public class Functions {
graphwin.drawDot(x, y);
}
/*
Global variables are accessible across scripts.
*/
/**
* Set a global variable.
*
* @param name The variable name
* @param var The variable
*/
public static void global(String name, Object var) {
GLOBALS.put(name, var);
}
/**
* 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);
}
// TODO: Make globals work!
// /*
// Global variables are accessible across scripts.
// */
// /**
// * Set a global variable.
// *
// * @param name The variable name
// * @param var The variable
// */
// public static void global(String name, Object var) {
// GLOBALS.put(name, var);
// }
//
// /**
// * 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

@ -215,12 +215,15 @@ public class Globals extends javax.swing.JInternalFrame {
if (keyList.getSelectedValue() != null) {
valBox.setEditable(true);
try {
Object item = Functions.GLOBALS.get(
keyList.getSelectedValue());
if (item.getClass().equals(sun.org.mozilla.javascript.internal.NativeArray.class)) {
Object[] arr = ((sun.org.mozilla.javascript.internal.NativeArray) item).toArray();
valBox.setText(Arrays.toString(arr));
valBox.setEditable(false);
Object item = Functions.GLOBALS.get(keyList.getSelectedValue());
/*if (item.getClass().equals(sun.org.mozilla.javascript.internal.NativeArray.class)) {
Object[] arr = ((sun.org.mozilla.javascript.internal.NativeArray) item).toArray();
valBox.setText(Arrays.toString(arr));
valBox.setEditable(false);
} else */
if (item == null) {
valBox.setText("");
valBox.setEditable(true);
} else if (item.getClass().equals(org.mozilla.javascript.NativeArray.class)) {
Object[] arr = ((org.mozilla.javascript.NativeArray) item).toArray();
valBox.setText(Arrays.toString(arr));

@ -191,12 +191,10 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="displaySettingsBtn" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="globalsBtn" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="arrangeWindowsBtn" min="-2" pref="57" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="helpBtn" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="77" max="-2" attributes="0"/>
<Component id="jLabel3" pref="439" max="32767" attributes="0"/>
</Group>
</Group>
@ -209,7 +207,6 @@
<Component id="arrangeWindowsBtn" alignment="0" max="32767" attributes="0"/>
<Component id="displaySettingsBtn" alignment="0" max="32767" attributes="0"/>
<Component id="helpBtn" alignment="0" max="32767" attributes="0"/>
<Component id="globalsBtn" alignment="1" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
@ -289,26 +286,6 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="helpBtnActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="globalsBtn">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/net/apocalypselabs/symat/images/globals.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Vars"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
<EmptyBorder bottom="5" left="5" right="5" top="5"/>
</Border>
</Property>
<Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="opaque" type="boolean" value="false"/>
<Property name="verticalTextPosition" type="int" value="3"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="globalsBtnActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel5">

@ -325,7 +325,6 @@ public class MainGUI extends javax.swing.JFrame {
arrangeWindowsBtn = new javax.swing.JButton();
displaySettingsBtn = new javax.swing.JButton();
helpBtn = new javax.swing.JButton();
globalsBtn = new javax.swing.JButton();
jPanel5 = new javax.swing.JPanel();
wikiBtn = new javax.swing.JButton();
jLabel4 = new javax.swing.JLabel();
@ -483,19 +482,6 @@ public class MainGUI extends javax.swing.JFrame {
}
});
globalsBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/net/apocalypselabs/symat/images/globals.png"))); // NOI18N
globalsBtn.setText("Vars");
globalsBtn.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
globalsBtn.setFocusable(false);
globalsBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
globalsBtn.setOpaque(false);
globalsBtn.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
globalsBtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
globalsBtnActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
@ -504,12 +490,10 @@ public class MainGUI extends javax.swing.JFrame {
.addContainerGap()
.addComponent(displaySettingsBtn)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(globalsBtn)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(arrangeWindowsBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(helpBtn)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGap(77, 77, 77)
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 439, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
@ -519,8 +503,7 @@ public class MainGUI extends javax.swing.JFrame {
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(arrangeWindowsBtn, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(displaySettingsBtn, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(helpBtn, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(globalsBtn, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(helpBtn, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
@ -793,10 +776,6 @@ public class MainGUI extends javax.swing.JFrame {
loadFrame(new WebBrowser("SyMAT Wiki", "http://wiki.symatapp.com", WebBrowser.WIKI_LOGO));
}//GEN-LAST:event_wikiBtnActionPerformed
private void globalsBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_globalsBtnActionPerformed
loadFrame(new Globals());
}//GEN-LAST:event_globalsBtnActionPerformed
private void forumBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_forumBtnActionPerformed
loadFrame(new WebBrowser("Community Forum", "http://forum.symatapp.com/", WebBrowser.FORUM_LOGO));
}//GEN-LAST:event_forumBtnActionPerformed
@ -961,7 +940,6 @@ public class MainGUI extends javax.swing.JFrame {
public static javax.swing.JButton displaySettingsBtn;
public static javax.swing.JButton editorBtn;
public static javax.swing.JButton forumBtn;
public static javax.swing.JButton globalsBtn;
public static javax.swing.JButton graphBtn;
public static javax.swing.JButton helpBtn;
public static javax.swing.JLabel jLabel1;

@ -29,8 +29,4 @@ def drawdot(x, y):
def simplify(expr):
return _.simplify(expr)
def vpa(expr):
return _.vpa(expr)
def setglobal(key,val):
_.setglobal(key,val)
def getglobal(key):
return _.getglobal(key)
return _.vpa(expr)

@ -5,8 +5,8 @@
<body>
<h1>Getting Started</h1>
<p>Open a new shell by clicking the button.
<br>Try typing commands, like "2*2" or "sin[.5]".
<br>You can make variables too, try "x=.5" then "sin[x]".
<br>Try typing commands, like "2*2" or "sin(.5)".
<br>You can make variables too, try "x=.5" then "sin(x)".
<br><br>SyMAT keeps track of the last few commands you enter in a shell.
To run one again, use the up and down keys to navigate the history.</p>
</body>

@ -14,8 +14,6 @@
<br>&nbsp;&nbsp;&nbsp;<i>Aliases: sym</i>
<br><b>simplify("expr")</b> Simplifies the given expression.
<br><b>vpa("expr")</b> Attempts to find the numerical value of "expr".
<br><b>global("name",value)</b> Sets global variable "name" to value.
<br><b>global("name")</b> Gets the global variable with id "name".
<br><b>replace("text", "find", "replace")</b> Returns "text" with all occurrences of "find" changed to "replace".
<br><b>subs("function", "var", "replace")</b> Replaces all occurrences of "var" with "replace" and solves.
Returns the answer or 0.0 if there is no numerical answer.

@ -7,8 +7,6 @@ deg(0)|Convert a given number in radians to degrees.
subs('',"x")|Solve an equation for the second argument.
simplify('')|Simplify the given function.
vpa('')|Computes numerical value or simplifies.
setglobal("", obj)|Set global variable with the given id.
getglobal("")|Get global variable with the given id.
plot()|Show the plot window.
plot('')|Graph the given function.
plotname("")|Sets the title of the graph window.

@ -14,8 +14,6 @@ plotclr()|Reset the graph.
drawdot(x, y)|Places a dot at the given coordinates.
simplify('')|Simplify the given function.
vpa('')|Computes numerical value or simplifies.
global("", obj)|Set global variable with the given id.
global("")|Get global variable with the given id.
fabs(0)|Absolute value of number.
asin(0)|
acos(0)|

Loading…
Cancel
Save