Abacus Legal syntax
Basic cell definitions
Text that appears in italics is supposed to mean what you should enter in a cell.
A cell in Abacus can be of three types, and therefor there are three main rules you have to be aware of
when you're defining a cell in Abacus:
- A cell starting with a number (0...9) is considered to be a number.
- A cell starting with a character (A..Z,a..z) or a quote (", ') is considered to be a string.
- A cell starting with en equal sign (=) is considered to be an equation.
You can reference to the value of another cell simple by typing in the cell coordinates that it has. For example,
A3 is a legal reference to the cell which has the x coordinate A and the y coordinate 3. Let's say that you want
to define the value of cell A1 to equal the value of cell A3. You can not just write A3 in cell A1.
Why not? It's simple! Consider the rules above, and you'll clearly see that A3 falls into the second category
of cell definitions. A text string will never be evaluated, in fact, should you ever try to evaluate a textstring (by
referencing it from another cell) it will evaluate to zero. Back on track now, to fix the problem with referencing to
cell A3 you have to write (in cell A1) =A3.
In the same way, should you want to comment out a cell (containing a value or an equation), just put a " or
a ' in front of it. The following will evaluate to 0 (if you don't see why, reread this page) '=A3*100-2.
That makes sense, doesn't it?
The spreadsheets power: Equations
As you can guess from the topic, a spreadsheet is pretty useless without equations. So, what is an equation then?
You've already seen one equation, namely '=A1*100-2. One important point when working with a spreadsheet
is that when you're dealing with equations or numbers in cells, the visible part of the cell is what they equals/evaluates
to, and not what their definition is. Let's imagine that the cell A1 contains the number 2. Then the equation above will
equal 198, and in the same cell that '=A1*100-2 is defined it will show 198 on the screen. If you were to change
the value of A1, then the value of the referencing equation is changed immediately.
There are a few rules you must obey when you're working with equations:
- An equation may contain numbers (0..9) and the arithmetic operators +, -, *, and /. An equation may also contain
a reference to another cell, as in A3, or a function, as in max(3, 7). We'll take about functions later on,
so you should just forget about them for now.
- Two arithmetic operators may not follow upon each other, as this results in a syntax error. This is no
surprise since the mathematical language hasn't defined the behaviour of (for example) 3+*98//7-+*7. This
kind of jibberish is disallowed.
- Should a cell reference to itself, or to another cell that in turn references it, a circular dependency is generated. Say
that A1 equals =B1+1 and B1 equals =A1, then you have a circular dependency. These are not allowed
to be in a spreadsheet, as the spreadsheet doesn't know when to break the loop (and thus never will).
The working horses in a spreadsheet: Functions
A function generates an answer based on the inputs. This might not mean anything to you, but it helps me justify that
we should cover one more form of cell referencing, namely blocks (or ranges). A block is defined
like A1:B4 and covers all cells within that interval, such as A3 and B1.
Blocks are very useful, since they releive you of some very tedious tasks. Say, for example, that you want to calculate
the sum of all elements in the block A1:B4, without the block concept you'd have to write =sum(A1,A2,A3,A4,B1,B2,B3,B4)
which, as you can see, really sucks. To remedy this, you can write =sum(A1:B4) instead.
Functions can have these forms:
- function() -- Has got no parameters, and therefore you can not control it's value.
- function(value) -- This one's got one parameter, which can be something like 23, A2, or A3+(B7/D9),
or it can even be another function!
- function(block) -- This one's already been exlpained.
- function(value, value, block) -- This one takes three parameters, the first two are just two values, and the third is
an arbitrary number of values (as many as there is in the block).
- function(block, block, ..., ..., block) -- Here's the gold nugget of functions. They take an arbritrary number of parameters,
each one that has an arbritrary number of values. The sum function is like this, in that it can take just about any number of parameters.
Useful things: Constants
There's a number of predefined constants in Abacus. A constant is a value that you cannot change, but you might use it
often, so that it's utterly boring to type it in everytime. One such constant is pi. It holds the value 3.141256... and
can be used like this: =A3*(pi/180).
Last updated on 14:th july by Bjorn Tornqvist