?, ?? , quit, restart, Ctrl-C .

# Running Yacas

This section describes the special commands for the Yacas interactive sessions (for example, to restart or to exit the interpreter). These commands are not functions but special directives that only apply while running Yacas interactively. They should not be used in scripts.

?, ?? | get online help
quit, restart, Ctrl-C | basic session control

##

Interactive session commands

###

?, ?? -- get online help

##### Internal function

##### Calling format:

    ?function
    ??

##### Parameters:

`function` -- name of function or keyword to request help on

##### Description:

The directive `?` is used to request online help while running an interactive session. A name of a function or a help keyword can be specified. The corresponding reference manual section will be shown. (There is a special glossary section that contains keywords and explains some of the Yacas terminology.)

Function names should be given without quotes. Note that function names are case-sensitive in Yacas but the `?` facility will also respond to all lowercase names.

The directive `??` displays the index to all documentation.

Documentation is displayed in a Web browser of your choice. The default choice is `lynx`. An alternative browser can be set using the `SetHelpBrowser` function.

##### Examples:

Get help on a function:

    In> ?Random

The function name can be given in all lowercase:

    In> ?makefunctionplugin

Get help on a keyword:

    In> ?arity

Browse all documentation:

    In> ??

##### See also:

Help , SetHelpBrowser .

###

quit, restart, Ctrl-C -- basic session control

##### Internal function

##### Calling format:

    quit
    restart

##### Description:

Type `quit` or `restart` at the Yacas prompt to exit or to restart the interpreter.

The directives `quit` and `restart` are not reserved words or variable names. They take effect only when typed as first characters at a prompt.

Pressing `Ctrl-C` will stop the currently running calculation. If there is no currently running calculation, `Ctrl-C` will quit the interpreter.

When the interpreter quits, it saves the command history (so quitting by `Ctrl-C` does not mean a "crash").

##### Examples:

To be effective, the directive must be typed immediately after the prompt:

    In> quit
    Quitting...

We can use variables named `quit`:

    In> 1+quit
    Out> quit+1;

There is no effect if we type some spaces first:

    In>       restart
    Out> restart;

##### See also:

Exit .

##

Command-line options

The default operation of `Yacas` is to run in the interactive console mode. `Yacas` accepts several options that modify its operation. Here is a summary of options:

- filename ... (read and execute a file or several files)
- `-c` (omit line prompts)
- `-d` (print default directory)
- `-v` (print version information)
- `-f` (execute standard input as one statement)
- `-p` (do not use terminal capabilities)
- `-t` (enable extra history features)
- `--archive` filename (use a given library archive file)
- `--init` filename (use a given initial file)
- `--patchload` (use `PatchLoad` to load files)
- `--rootdir` directory`/` (specify library directory)
- `--server` port (start `Yacas` as a network server on given port)
- `--verbose-debug` (turn on showing some additional debugging information on screen) Options can be combined, for example,

      yacas -pc filename

  will read and execute the file `filename` non-interactively without using terminal capabilities and without printing prompts.

Here is a more detailed description of the command-line options.

    yacas -c

Inhibit printing of prompts `In>` and `Out>`. Useful for non-interactive sessions.

    yacas -f

Reads standard input as one file, but executes only the first statement in it. (You may want to use a statement block to have several statements executed.)

    yacas -p

Does not use terminal capabilities, no fancy editing on the command line and no escape sequences printed. Useful for non-interactive sessions.

    yacas -t

Enable some extra history recall functionality in console mode: after executing a command from the history list, the next unmodified command from the history list will be automatically entered on the command line.

    yacas [options] {filename}

Reads and executes commands in the filename and exits. Equivalent to `Load()`.

    yacas -v

Prints version information and exits. (This is the same information as returned by `Version()`.)

    yacas -d

Prints the path to the `Yacas` default library directory (this information is compiled into the `Yacas` executable) and exits.

    yacas --patchload

Will load every file on the command line with the `PatchLoad` command instead of the normal `Load` command, This is useful for generating HTML pages for a web site using the `Yacas` scripting language, much like you can do with the PHP scripting language.

    yacas --init [file]

Tells the system to load `file` as the initialization file. By default it loads the file `yacasinit.ys` from the scripts directory.

    yacas --server <port>

On some platforms server mode can be enabled at build time by passing the flag `--enable-server` to the `./configure` script. `Yacas` then allows you to pass the flag `--server` with a port number behind it, and the `Yacas` executable will listen to the socket behind that port instead of waiting for user input on the console.

Commands can be sent to the server by sending a text line as one block of data, and the server will respond back with another text block.

One can test this function by using `telnet`. First, set up the server by calling

    yacas --server 9734

and then invoke `telnet` in another window, for example:

    telnet 127.0.0.1 9734

Then type a line of Yacas input and hit Enter. The result will be one line that you will get back from the Yacas server.

Some security measures and resource management measures have been taken. No more than 10 connections can be alive at any time, a calculation cannot take more than 30 seconds, and `Yacas` operates in the secure mode, much like calling an expression by passing it as an argument to the `Secure` function. This means that no system calls are allowed, and no writing to local files, amongst other things. Something that has not been taken care of yet is memory use. A calculation could take up all memory, but not for longer than 30 seconds.

The server is single-threaded, but has persistent sessions for at most 10 users at a time, from which it can service requests in a sequenial order. To make the service multi-threaded, a solution might be to have a proxy in front of the service listening to the port, redirecting it to different processes which get started up for users (this has not been tried yet).

    yacas --rootdir [directory]/

Tells the system where to find the library scripts. Here, `directory/` is a path that is passed to `DefaultDirectory`, and file names will be simply appended to it, so you should make sure to include a forward or backward slash (depending on the platform) at the end. It is also possible to give a list of directories, separated by a colon, eg. `yacas --rootdir scripts/:morescripts/`.

    yacas --archive [file]

Use a compressed archive instead of the script library.

`Yacas` has an experimental system where files can be compressed into one file, and accessed through this command line option. The advantages are:

- Smaller disk/memory use (useful if `Yacas` is used on small hand-held computers).
- No problems with directory path separators: "`path`/`file`" will always resolve to the right file, no matter what platform (read: Windows) it runs on.
- The start-up time of the program might improve a little, since a smaller file is loaded from disk (disk access being slow), and then decompressed in memory, which might be a lot faster than loading from disk.

An additional savings is due to the fact that the script files are stripped from white spaces and comments, making them smaller and faster loading.

To prepare the compressed library archive, go into the `ramscripts/` directory and type

    make -f makefile.compressor

The result should be the archive file `scripts.dat`. Then launch `Yacas` with the command line option `--archive scripts.dat`, with the file `scripts.dat` in the current directory.

The reason that the `scripts.dat` file is not built automatically is that it is not tested, at this time, that the build process works on all platforms. (Right now it works on Unix, MacOSX, and Win32.)

Alternatively, configure Yacas with

    ./configure --enable-archive

and the archive file `scripts.dat` will be created in the `ramscripts/` subdirectory.

When an archive is present, Yacas will try to load it before it looks for scripts from the library directories. Typing

    make archivetest -f makefile.compressor

in the `ramscripts/` directory runs all the test scripts using the archived files.

The currently supported compression schemes are uncompressed and compressed with `minilzo`. Script file stripping (removing whitespace and comments) may be disabled by editing `compressor.cpp` (variable `strip_script`).