|
3.6 Input and outputSINGULAR's input and output (short, I/O) are 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. Themonitor command enables and disables this feature
(see monitor).
How to use linksRecall that links are the communication channels of SINGULAR, i.e., something SINGULAR can write to and read from using the functionswrite and read . There are furthermore
the functions dump and getdump which store resp.
retrieve the content of an entire SINGULAR session to, resp. from,
a link. The dump and getdump commands are not available
for DBM links.
For more information, see write, read, dump, getdump. Example:
Specifying a link can be as easy as specifying a filename as a string.
Links do not even 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 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 commandexecute (see execute).
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:
Ssi 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 ssi format. Reading from an ssi link returns the written expressions (i.e., not a string, in general).Ssi links should primarily be used for communicating with other programs or for parallel computations (see, for example, Parallelization with ssi links). See Ssi 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:
|