mavscript
Copyright (c) A.Vontobel, 2004 - 2016
With Mavscript you can do calculations in a text document.
The following file formats are supported:
- Text files
- OpenDocument Text odt (OpenOffice, LibreOffice)
- Hypertext html
- LaTeX tex (pdflatex, xelatex)
- other text based formats (i.e. svg). The
text file may be packed in a zip-archive.
File format with limited support:
- OfficeOpenXML docx (MS Word).
Experimentally supported. Automatic language detection shall be turned off in Word.
How it works
Mavscript reads the calculation commands in the template.
These commands start with the control characters
§m and end with one of the following control
characters: §i,
§o, §io und
§n. Their meaning will be explained
later. The commands are forwarded to
the Computer-Algebra-System (Yacas). The algebra
program returns an answer to Mavscript, i.e. the result of the
calculation command. Mavscript now can insert this answer in the
text, where the command was. When all calculations are done
Mavscript saves the text document in a new file out-template.
The template file remains unchanged.
You do not always want to replace the calculation command by the
answer from the algebra program. When you assign a value to a
variable you usually want that the command remains in the text.
Therefore there are the following possibilites.
Input in the template file Output Notes
-------------------------- ------ -----
§m l:=5 §i l:=5 The command remains unchanged. §i stands for input.
§m b:=4 §i b:=4 The control characters are removed.
§m h:=2 §i m h:=2 m
§m V:=l*b*h §io V:=l*b*h --> 40 Both the input and the output are shown.
§m 2 + 3*4 §io 2 + 3*4 --> 14 §io stands for input/output.
§m doubleVol := 2*V §n Sometimes you do not want to show the command or its result.
§m gl:=x^2-l^2 §n §n stands for nothing.
§m doubleVol §o 80 Only the return value (answer) is shown. §o stands for output.
§m Solve(gl,x) §o {x==5,x==(-5)} This is useful if you want to separate the calculation and
the results.
Some rules:
- A command must be placed in a single line. (Exceptions: odt, docx)
- Several commands may be in the same line.
Example: §m a:=3 §i,
§m b:=4 §i.
- Mavscript attaches a semicolon
(;) to each command. Therefore the
semicolon can be omitted in the commands.
- In OpenOffice Writer and Word the entire
command shall be formatted the same way.
-
The syntax of the commands depends on the
algebra program used.
- For the built-in program
Yacas (default mode) an Introduction and the
Function Reference are enclosed in the directory
path-to-mavscript/INFO/yacas.
- In addition to Yacas
the Java-Interpreter BeanShell is built-in. The manual is
enclosed in the directory
path-to-mavscript/INFO/beanshell .
- Experimentally the computer-algebra-system
Jasymca is built-in. The manual is
enclosed in the directory
path-to-mavscript/INFO/jasymca .
- The last possibility is to let Mavscript connect to a
Port (on localhost or on a remote server).
Mavscript vs. spread sheet applications
The goal of
Mavscript is to allow calculations in a text document. Mainly
Mavscript is used where spread sheet applications are not that
much suitable: The mathematical functionality may be insufficient
(algebra!) or the calculations are to much hidden (hard to
debug, hard to understand for others). In such cases the use of
Mavscript with a computer-algebra-system, such a yacas, shows to
be favourable.
The disadvantage compared to a spread sheet application is less
interactivity, especially when using graphs that depend on
the results.
Installation
see How to install
Usage
STANDARD
If Mavscript has been installed as described and the included
algebra program yacas is used:
- Create a template (input) file:
template.txt, template.html
or template.odt
- Drag the template file with the
mouse on the Mavscript-icon on the
desktop.
- A window opens and the calculation is
executed. When finished, check if there is an error message and
close the window.
- Open the output file (out-template.txt,
out-template.html or
out-template.odt) .
ALTERNATE (in order to use advanced functions or if the standard procedure does not work)
Mavscript alternately can be called out of the shell (command prompt, konsole, terminal).
cd path-to-mavscript and then:
- mavscript-yacas inputfile (Windows)
- ./mavscript-yacas inputfile (Linux, Mac)
- java -jar mavscript*.jar inputfile (all platforms)
ENHANCED FUNCTIONS
Mavscript can also be connected to stdin and stdout pipes:
cat inputfile | mavscript-yacas > outputfile or
echo '§m nf(Pi*8^2,1) §io' | mavscript-yacas (answering "nf(Pi*8^2,1) --> 201.1")
Disclaimer
- Use it at your own risk. Mavscript comes
with ABSOLUTELY NO WARRANTY.
- The program Mavscript is subject to the
free Licence GPL. It is included in the file
path-to-mavscript/INFO/LICENCE-GPL.txt . The licence allows the
usage of the program, but does impose clear rules if you intend
to distribute it. Mavscript is copyrighted by A.Vontobel.
- The computer-algebra-system Yacas
that is included is subject to the free licence LGPL. It is included in the file
path-to-mavscript/INFO/yacas/COPYING .
The licence allows the usage of the program, but does impose clear
rules if you intend to distribute it.
- The Java-Interpreter BeanShell
that is included is subject to the free licence LGPL. It is included in the file
path-to-mavscript/INFO/beanshell/LGPL.txt .
The licence allows the usage of the program, but does impose clear
rules if you intend to distribute it.
The computer-algebra-system Jasymca
that is included is subject to the free licence GPL. It is included in the file
path-to-mavscript/INFO/jasymca/Copying.html .
The licence allows the usage of the program, but does impose clear
rules if you intend to distribute it.