|
3.6 Input and outputSINGULAR’s input and output (short, I/O) is realized using links. Links are the communication channels of SINGULAR, i.e., something SINGULAR can write to and read from. In this section, a short overview of the usage of links and of the different link types is given. For loading of libraries, see LIB. For executing program scripts, see filecmd. MonitoringA special form of I/O is monitoring. When monitoring is enabled,
SINGULAR makes a typescript of everything printed on your terminal
to a file. This is
useful to create a protocol of a SINGULAR session. The
How to use linksRecall that links are the communication channels of SINGULAR, i.e.,
something SINGULAR can write to and read from using the functions
For more information, see write, read, dump, getdump. Example:
Specifying a link can be as easy as specifying a filename as a string.
Except for MPtcp links, links even do not need to be explicitly opened
or closed before, resp. after, they are used. To explicitly open or
close a link, the Links have various properties which can be queried using the
Example:
ASCII linksData that can be converted to a string that can be written into files for
storage or communication with other programs. The data are written in
plain ASCII format. Reading from an ASCII link returns a string —
conversion into other data is up to the user. This can be done, for
example, using the command ASCII links should primarily be used for storing small amounts of data, especially if it might become necessary to manually inspect or manipulate the data. See ASCII links, for more information. Example:
MPfile linksData is stored in the binary MP format. Read and write access is very fast compared to ASCII links. All data (including such data that cannot be converted to a string) can be written to an MPfile link. Reading from an MPfile link returns the written expressions (i.e., not a string, in general). MPfile links should primarily be used for storing large amounts of data (like dumps of the content of an entire SINGULAR session), and if the data to be stored cannot be easily converted from or to a string (like rings, or maps). MPfile links are implemented on Unix-like operating systems only. See MPfile links, for more information. Example:
MPtcp linksData is communicated with other processes (e.g., SINGULAR processes) which may run on the same computer or on different ones. Data exchange is accomplished using TCP/IP links in the binary MP format. Reading from an MPtcp link returns the written expressions (i.e., not a string, in general). MPtcp links should primarily be used for communications with other programs or for parallel computations (see, for example, Parallelization with MPtcp links). MPtcp links are implemented on Unix-like operating systems only. See MPtcp links, for more information. Example:
DBM linksData is stored in and accessed from a data base. Writing is accomplished by a key and a value and associates the value with the key in the specified data base. Reading is accomplished w.r.t. a key, the value associated to it is returned. Both the key and the value have to be specified as strings. Hence, DBM links may be used only for data which may be converted to or from strings. DBM links should primarily be used when data needs to be accessed not in a sequential way (like with files) but in an associative way (like with data bases). See DBM links, for more information. Example:
|