Expressions


Expressions in AXE are programs that can operate on an AXE document or perform independant calculations.

There are two places you can use expressions:

The only difference between these two contexts is that in the calculator, expressions have no access to any particular document. When used from the library, they can use functions (described below) to read and write the currenct document. Expressions have a simple, vaguely C-like syntax.

AXE comes with some sample expressions already in the expression library. These are a good place to start.

Literals:

Literal numbers and strings are specified as in C. To specify the number 17, you could enter 17 or 0x11 or 0b10001 or 0c21 or 17.0. Points to note:

Variables:

Variables need not be declared. They come into existance whenever they are assigned to. Thus a=100*3; creates a variable 'a' and assigns the value 300 to it.

Operators:

A C-like range of operators is supported. The ++ and -- operators are not supported. Operator precedence is a little annoying; The use of parentheses is strongly advised.
Operators such as & and ^ that perform binary operations first convert the operands to integral types, then perform the binary operation, then convert them back to doubles.
The full range of operators is as follows:
+ - * / % ~ & | ^ << >> && || ! == != < > <= >= = += -= *= /= |= &= ^=

Arrays:

Variables become arrays if they are treated as arrays. Thus a[10] = 109; creates an array 'a' and assigns the value 109 to slot '10' in it. Array indexes may be expressions; thus b=10; a[b*2]=1; assigns the value 1 to slot '20' in array 'a'.

Functions:

Functions are called as in C, with comma-separated arguments enclosed in parentheses. You may not define your own functions; you can only use the built-in ones. Future versions of AXE will probably use a different, much more powerful scripting language.

Statements:

Statements end with a ; as in C. If you forget the ;, the Calculator will try and add one for you.

Loops:

Loops look like C loops. To set 'i' to every value from 0 to 99 inclusive, do this:

				for(i=0;i<100;i+=1) 
				{ 
					array[i]=i; 
				}
			
Note that as there is no ++ operator, we had to write i+=1.

Conditionals:

The only conditional is 'if'. It is used as in C:

				if (i > (b+100)) 
				{ 
					msgbox("i is a lot bigger than b"); 
				} 
				else 
				{ 
					msgbox("i isn't really all that big"); 
				} 

The built-in functions are divided into general maths functions, and functions that are specific to AXE and operate on the document itself. Mathematical functions are:

AXE-specific functions are: