Register Login


Functions > Miscellaneous Functions


The following functions are described in this Section:

01. constants 02. echo 03. format 04. getstring
05. getusernum 06. getuserstr 07. messagebox 08. plot
09. savefile 10. ticks 11. unit 12. vars

constants

Displays names of all the constants defined by Math Processor. You cannot change or remove the value of a constant.

echo

Expects one or more arguments. All the arguments are converted to a text representation and then the Math Processor engine sends the resulting text to the GUI module. It is up to the GUI module to decide how to deal with the output request. A compiling GUI will, in general, output the text on the screen

format

By default, Math Processor shows the numerical output in fixed precision format using 4 decimal digits. The format directive can be used to get or set the output format. It has two forms:

  1. If no argument is passed, shows the current number format.
  2. If format is passed as argument, it will be used to format numbers for subsequent output. Following values can be passed as format. For each format, digit is a digit between 0 and 99.
    • E or e followed by digit: Scientific notation.
    • F or f followed by digit: Fixed point precision.
    • G or g followed by digit: General number format.
    • N or n followed by digit: Number. Uses group seprators.
    • P or p followed by digit: Percentage.
    • R or r followed by digit: Round trip.

getstring

Returns a variable of type "Text" containing text representation of the passed argument. The passed argument can be of type text, vector (number or array), matrix or bool. In case of numerical argument, an extra argument can be passed as the number format. To see what number formats are allowed, please refer to the format function.

getusernum

Displays an input box to get numeric input from the user. It has the following form

getusernum(message)

getuserstr

Displays an input box to get text input from the user. It has the following form

getuserstr(message)

messagebox

Displays a message box. Its format is:

messagebox(title, message)

Note: Do not forget to enclose text inside quotations marks if it contains spaces.

plot

Creates simple line graph for the given arrays of data containing x and y values respectively. Its format is:

plot(array_1a, array_1b, [color], array_2a, array_2b, [color], ......)

The [color] parameters are optional. The dots at the end show that the function can create as many line graphs in the same call as you require. The arrays are always passed in pairs (i.e. against x & y coordinates of the Cartesian plane respectively). After each pair of arrays, you can optionally give the desired color (e.g. green, darkgreen, red etc.) using which the plot could be drawn. If no color value is provided, the plotting module provides a color of its own choice. For the list of all possible color values, please refer to this MSDN article.

savefile

Allows to export data to a file e.g. XML, .html or simple text files. It has the following two forms:

  1. savefile(data)
  2. savefile(data, path)

If the first form is used, the function will open a Save File Dialogue to allow the user to choose a location and file. If the second form is used, the file path/name are provided as the second parameter. The path can be relative (e.g. file.txt or absolute e.g. C:\file.txt).

ticks

Gives the number of milliseconds since the system started.

unit

By default, Math Processor uses Radian as standard unit for calculations e.g. in functions like sin, cos etc. The unit function can be used to get or set the unit of calculations. This function has the following form:

unit([deg|degrees|rad|radian])

The bracket around argument shows that it is optional. The pipe (|) signifies that one of the four provided values is to be used. deg/degrees will set the unit to degrees and rad/radians will set it to radians.

vars

Displays the names of all the variables that are currently defined. A variable is define using the assignment (=) operator. It can be undefine using the remove or removeall directives.