From f81db07bf107b75db7283d53613d31bc09d1bb06 Mon Sep 17 00:00:00 2001 From: skylarmt Date: Fri, 30 Jan 2015 15:35:28 -0700 Subject: [PATCH] Add aliases to Python so "_." prefix no longer needed, update documentation --- src/net/apocalypselabs/symat/CodeRunner.java | 2 +- src/net/apocalypselabs/symat/Functions.java | 10 ++++++ .../apocalypselabs/symat/SplashScreen.form | 2 +- .../apocalypselabs/symat/SplashScreen.java | 2 +- src/net/apocalypselabs/symat/functions.py | 24 ++++++-------- .../apocalypselabs/symat/help/commands.html | 4 +++ src/net/apocalypselabs/symat/help/editor.html | 6 +--- .../symat/resources/jsfunctions.txt | 4 +++ .../symat/resources/pyfunctions.txt | 32 +++++++++++-------- 9 files changed, 49 insertions(+), 37 deletions(-) diff --git a/src/net/apocalypselabs/symat/CodeRunner.java b/src/net/apocalypselabs/symat/CodeRunner.java index 66da2c7..3a1ed9c 100644 --- a/src/net/apocalypselabs/symat/CodeRunner.java +++ b/src/net/apocalypselabs/symat/CodeRunner.java @@ -193,7 +193,7 @@ public class CodeRunner { .getResourceAsStream("functions."+lang))); String line; while ((line = reader.readLine()) != null) { - text += line; + text += line+"\n"; } } catch (Exception e) { } diff --git a/src/net/apocalypselabs/symat/Functions.java b/src/net/apocalypselabs/symat/Functions.java index aa40d2a..1495337 100644 --- a/src/net/apocalypselabs/symat/Functions.java +++ b/src/net/apocalypselabs/symat/Functions.java @@ -243,6 +243,16 @@ public class Functions { 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. */ diff --git a/src/net/apocalypselabs/symat/SplashScreen.form b/src/net/apocalypselabs/symat/SplashScreen.form index 9041408..885b9a0 100644 --- a/src/net/apocalypselabs/symat/SplashScreen.form +++ b/src/net/apocalypselabs/symat/SplashScreen.form @@ -80,7 +80,7 @@ - + diff --git a/src/net/apocalypselabs/symat/SplashScreen.java b/src/net/apocalypselabs/symat/SplashScreen.java index 13f4ca5..79a0aa7 100644 --- a/src/net/apocalypselabs/symat/SplashScreen.java +++ b/src/net/apocalypselabs/symat/SplashScreen.java @@ -111,7 +111,7 @@ public class SplashScreen extends javax.swing.JFrame { jLabel1.setFont(MainGUI.ubuntuRegular.deriveFont(18.0F)); jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); - jLabel1.setText("Version "+MainGUI.VERSION_NAME); + jLabel1.setText("Version "+MainGUI.VERSION_NAME+""); jLabel1.setVerticalAlignment(javax.swing.SwingConstants.TOP); jLayeredPane1.add(jLabel1); jLabel1.setBounds(200, 110, 130, 30); diff --git a/src/net/apocalypselabs/symat/functions.py b/src/net/apocalypselabs/symat/functions.py index 203609e..80fe4d9 100644 --- a/src/net/apocalypselabs/symat/functions.py +++ b/src/net/apocalypselabs/symat/functions.py @@ -1,42 +1,36 @@ -'''def notify(msg): +def notify(msg): _.notify(msg) - def ask(msg): return _.ask(msg) - def diff(fun,var): return _.diff(fun,var) - def integrate(fun,var): return _.integrate(fun,var) - def rad(num): return _.rad(num) - def deg(num): return _.deg(num) - def subs(fun,var): return _.subs(fun,var) - def plot(): _.plot() - def plot(fun): _.plot(fun) - def plotname(fun): _.plotname(fun) - def plotname(): return _.plotname() - def xlim(min,max): _.xlim(min,max) - def plotclr(): _.plotclr() - def drawdot(x, y): _.drawdot(x, y) -''' \ No newline at end of file +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) \ No newline at end of file diff --git a/src/net/apocalypselabs/symat/help/commands.html b/src/net/apocalypselabs/symat/help/commands.html index 82a30cf..4071f83 100644 --- a/src/net/apocalypselabs/symat/help/commands.html +++ b/src/net/apocalypselabs/symat/help/commands.html @@ -12,6 +12,10 @@
integrate("3*x^2", "x") Returns the integral of the function with respect to the second argument.
$("command") Parses the given text with the Symja library.
   Aliases: sym +
simplify("expr") Simplifies the given expression. +
vpa("expr") Attempts to find the numerical value of "expr". +
global("name",value) Sets global variable "name" to value. +
global("name") Gets the global variable with id "name".
replace("text", "find", "replace") Returns "text" with all occurrences of "find" changed to "replace".
subs("function", "var", "replace") Replaces all occurrences of "var" with "replace" and solves. Returns the answer or 0.0 if there is no numerical answer. diff --git a/src/net/apocalypselabs/symat/help/editor.html b/src/net/apocalypselabs/symat/help/editor.html index c971336..0aef550 100644 --- a/src/net/apocalypselabs/symat/help/editor.html +++ b/src/net/apocalypselabs/symat/help/editor.html @@ -6,12 +6,8 @@

Code Editor

The code editor allows you to make scripts that can do many things.
Scripts can be written in JavaScript or in Python. -
To switch languages, use the Language option on the Edit menu. +
To switch languages, use the Language option on the Run menu.

-

Note: - Python scripts require - _. - before SyMAT commands.

Exporting Code

You can export syntax-highlighted (colored) code to HTML or PDF with the Export tool. This is useful for generating diff --git a/src/net/apocalypselabs/symat/resources/jsfunctions.txt b/src/net/apocalypselabs/symat/resources/jsfunctions.txt index e7c04f4..d7c1513 100644 --- a/src/net/apocalypselabs/symat/resources/jsfunctions.txt +++ b/src/net/apocalypselabs/symat/resources/jsfunctions.txt @@ -5,6 +5,10 @@ integrate('',"x")|Find the integral of the function passed with respect to the s rad(0)|Convert a given number in degrees to radians. 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. diff --git a/src/net/apocalypselabs/symat/resources/pyfunctions.txt b/src/net/apocalypselabs/symat/resources/pyfunctions.txt index 5b9d496..502da13 100644 --- a/src/net/apocalypselabs/symat/resources/pyfunctions.txt +++ b/src/net/apocalypselabs/symat/resources/pyfunctions.txt @@ -1,17 +1,21 @@ -_.notify("")|Display a message in a box. -_.ask("")|Ask a question in a box. Supply question text. -_.diff('',"x")|Find the derivative of the function passed with respect to the second argument. -_.integrate('',"x")|Find the integral of the function passed with respect to the second argument. -_.rad(0)|Convert a given number in degrees to radians. -_.deg(0)|Convert a given number in radians to degrees. -_.subs('',"x")|Solve an equation for the second argument. -_.plot()|Show the plot window. -_.plot('')|Graph the given function. -_.plotname("")|Sets the title of the graph window. -_.plotname()|Gets the title of the graph window. -_.xlim(min,max)|Sets the x-axis min and max values. Cannot be used after a formula has been graphed. -_.plotclr()|Reset the graph. -_.drawdot(x, y)|Places a dot at the given coordinates. +notify("")|Display a message in a box. +ask("")|Ask a question in a box. Supply question text. +diff('',"x")|Find the derivative of the function passed with respect to the second argument. +integrate('',"x")|Find the integral of the function passed with respect to the second argument. +rad(0)|Convert a given number in degrees to radians. +deg(0)|Convert a given number in radians to degrees. +subs('',"x")|Solve an equation for the second argument. +plot()|Show the plot window. +plot('')|Graph the given function. +plotname("")|Sets the title of the graph window. +plotname()|Gets the title of the graph window. +xlim(min,max)|Sets the x-axis min and max values. Cannot be used after a formula has been graphed. +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)|