# Getting started

This chapter is short introduction to the cross spreadsheet or axs. The spreadsheet is a special interpreter that provides special commands to manipulate spreadsheets, made out of sheet and folio. The axs interface is also designed to ease some operations like loading or saving sheets.

## Invocation and termination

The axs spreadsheet is started by typing the command `axs`. Once started, the spreadsheet reads the commands from the terminal. Since the spreadsheet is built on top of the interpreter, any command is in fact a special form that is executed by the interpreter. The natural way to invoke the debugger is to pass the primary file to execute with eventually some arguments.

zsh> axs PROGRAM [arguments]

When the spreadsheet is started, a prompt '(axs)' indicates that the session is running. The session is terminated like any interpreted session by using ctrl-d.

zsh> axs PROGRAM (axd)

### Spreadsheet options

The available options can be seen with the `-h` option and the current version with the `-v` option. This mode of operations is similar to the one found with the interpreter.

zsh> axs -h usage: axs [options] [file] [arguments] [h] print this help message [v] print version information [i] path add a path to the resolver [f assert] enable assertion checking

## Folio operations

The process of importing data requires first to create a folio which will act as a collection of sheets. When starting from the beginning, the best way is to create a new folio and then create, one or several sheets in which data can be added or imported.

### Creating a folio

The process of importing data requires first to create a folio. When starting from the beginning, the best way is to create a new folio with the `axs:new` command, then create one or several sheets with the `axs:create` command and finally import data with the `axs:import` command.

(axs) axs:new "elements"

The `axs:new` command creates a new folio those name is given by the argument. Without argument, the command creates an unnamed folio. The command also returns the `Folio` object that can be later used for special operations.

### Saving a folio

The `axs:save` command writes a binary representation of the folio in a file. The folio is serialized with the help of the serialize engine. The serialization is done in a file that can be reloaded with the `axs:open` command.

(axs) axs:save "elements.xss" (axs) axs:open "elements.xss"

### Creating a default sheet

In order to import data, a sheet must be created in the folio. The `axs:create` command creates a sheet in the folio. The command take an optional argument which is the sheet name. The command also returns the `Sheet` object that can be used for other special processing.

(axs) axs:create "data"

A new sheet named data is created and becoming the default one. Once the sheet is created, the data can be added into it with the help of the `axs:import` command. There is always a default sheet attached to a folio. The default sheet is set by creating a new sheet or by using the `axs:select` command.

### Importing data in the sheet

The periodic table of the elements is a simple example that illustrates the importation process. The original file is located into the exp/elem directory. The elements.tbl file is a simple file that associates the atomic number with an element name, it chemical symbol and other parameters. An extract of the file is shown below.

# ------------------------------------------------------------ # - elements.tbl - # - the periodic sheet of elements - # ------------------------------------------------------------ # - element name sym weight bp (c) mp (c) density - # ------------------------------------------------------------

1 "Hydrogen" "H" 1.00797 -252.7 -259.2 0.071 2 "Helium" "He" 4.0026 -268.9 -269.7 0.126 3 "Lithium" "Li" 6.939 1330 180.5 0.53 4 "Beryllium" "Be" 9.0122 2770 1277 1.85 5 "Boron" "B" 10.811 nil 2030 2.34

There are 112 rows in this sheet. Not all rows have data. A particular cell, with no data is marked with the special symbol `nil`. Strings are enclosed with double quotes. Integer and reals numbers differentiate themselves automatically. A line with no data is ignored. A comment starts with the `#` character.

(axs) axs:new "elements" (axs) axs:create "data" (axs) axs:import "elements.tbl" (axs) axs:save "elements.xss"

After the `axs:import` command, the `axs:save` command writes the folio in a file called elements.xss. Such file can be later used with the `axs:open` command.

### Folio reloading

Given a folio, the `axs:open` command reload the folio in memory and permit the sheet manipulation. When a folio is loaded, the default sheet can be selected. Using the previous example, and assuming a new session is started:

# reload the folio (axs) axs:open "elements.xss"

When the folio is loaded, the first sheet is set as the default sheet.

### Folio information

When the folio is loaded, the `axs:info` command reports some information about the folio.

(axs)axs:info Object Value Folio name elements Current sheet data

In the previous example, the folio name is reported as well as the default sheet.

## Sheet operations

Sheets can be manipulated once loaded into a folio. There is always a default sheet on which most of the operation apply. In certain cases, the operations can also be done with the help of the sheet index.

### Sheet information

The `axs:list` command displays the folio content with the sheet index, sheet name and sheet length. This command permits to check, among other things, that an importation process operated correctly.

(axs)axs:list Sheet index Sheet name Sheet length 0 data 112

The command reports for each sheet, its name and size. The size is the number of records which is the number of rows. After a `axs:create` command, the `axs:list` command will report a sheet without element.

### Viewing the sheet contents

The best way to visualize the sheet content is to use the `axs:view` command. The command operates with the default sheet. Without argument, the whole sheet is shown. With one argument, an integer number that specifies the report length and eventually a secondary number that specifies the starting index.

(axs)axs:view 5 10 11 Sodium Na 22.989800 892 97.800000 .97 12 Magnesium Mg 24.312000 1107 650 1.740000 13 Aluminum Al 26.981500 2450 660 2.700000 14 Silicon Si 28.086000 2680 1410 2.330000 15 Phosphorus P 30.984000 nil nil nil

### Sorting a sheet

The `axs:sort` command sorts the default sheet. The sheet column as well as well as the sorting mode are the sorting parameters. Without argument the first column and the ascending mode are used to sort the sheet. For example, a sorting on the second column in ascending order, produces the following result:

(axs)axs:sort 1 (axs)axs:view 5 95 Americium Am 243.060000 nil nil nil 13 Aluminum Al 26.981500 2450 660 2.700000 18 Argon Ar 39.948000 -185.800000 -189.400000 1.400000 33 Arsenic As 74.992000 613 817 5.720000 51 Antimony Sb 121.750000 1380 630.500000 6.620000

On the other end, sorting in descending order produces the following result:

(axs)axs:sort 1 (axs)axs:view 5 40 Zirconium Zr 91.220000 3580 1852 6.490000 30 Zinc Zn 65.370000 906 419.500000 7.140000 70 Ytterbium Yb 173.040000 1427 824 6.980000 39 Yttrium Y 88.905900 nil nil nil 54 Xenon Xe 131.300000 -108 -111.900000 3.060000