Mathscript Documentation


Functions

NameDescriptionUsageTranslation to Arithmetic
initInitialize the program.initN/A
addAdds two numbers.add <number1> <number2>number1 + number2
subSubtracts two numbers.sub <number1> <number2>number1 - number2
mulMultiplies two numbers.mul <number1> <number2>number1 * number2
divDivides two numbers.div <number1> <number2>number1 / number2
varDefine a numerical variable.var [name] <number>N/A
setSet a variable to a value.set [name] <number>N/A
getGet the value of a variable.get [name]N/A
resetResets all variables.resetN/A

System Variables

NameDescription
ansThe most recent answer returned by a function.


Initializing the Program

To initialize a Mathscript script, type 'init' as a line. Any code before the 'init' line will be ignored.

Example script for initializing:


		Everything before init will be ignored.
		add 0 0
		sub 9 6
		init
		add 3 6
	

Output:

		9.0
	

Program Output

When an arithmetic function, such as 'add', is called, the output will always be printed out to the console. When a non-arithmetic function, such as 'var' is called, the system will not return anything. However, there are still some other system functions which print to the console, such as 'get'.

Example script for output:


		init
		add 0 3
		var i 8
		get i
	

Output:


		3.0
		8.0
	

Errors

In it's current state, Mathscript will not generate any error messages. Instead, it will just ignore the erroneous lines.

Example script for errors:


		init
		add 0 3
		asdflskdjfsldfjsfakjsfjfskf
	

Output:


		3.0
	

Comments

Since Mathscript ignores erroneous lines, comment lines can just be written out normally. If you want to comment out a line of code, just add a symbol such as '#' and then a space to the beginning of the line. You can also write things like directions before initializing the program, as all lines before the 'init' line will be ignored.

Example script for errors:


		init
		div 1 2
		This line will be ignored.
		# add 0 6
		The line above was ignored.
	

Output:


		0.5
	



© 2021 Helix Development Group