Asymptote/File IO

From Wikibooks, open books for an open world
Jump to: navigation, search

This section contains a discussion of the various file manipulation capabilities of Asymptote. It covers image files outputs, source code includes and data file input and output.

Image Files[edit]

Image files are created by calling the shipout function. However, this need not be explicitly included.

Source Files[edit]

Many useful modules, as discussed in the Asymptote main page, can be imported using the file import routine; for example:

import graph.asy;

would give access to the numerous graphing functions contained in the file graph.asy.

According to the software documentation (http://asymptote.sourceforge.net), Asymptote will search for module files in the following directories (in order):

  1. The current directory;
  2. The directory .asy in the user’s home directory (%USERPROFILE%\.asy under MSDOS);
  3. A list of one or more directories specified by the configuration variable dir (separated by : under UNIX and ; under MSDOS);
  4. The Asymptote system directory (by default, /usr/local/share/asymptote under UNIX and C:\Program Files\Asymptote under MSDOS).

The working directory can be changed using the command

string cd(string directory_string);

The return value is the new directory. If directory_string is an empty string, the system returns to the working directory at startup. Note: the option -global or -unsafe must be enabled to change the working directory.

Data Files[edit]

Data files can be input and output