Files and Databases
APLX offers a range of features for accessing data in files. These include facilities both for storing and retrieving data within your APL applications, and for exchanging data with other applications. They include:
For simple APL applications, you can often keep all the data you need in the current workspace in APL variables. However, for more sophisticated applications, this may not fit your requirements. For example, if you wrote a suite of functions which produced monthly profit and loss accounts, you might want to store the data for each month separately. You could arrange to keep the data in a series of stored workspaces, but you would not want to replicate the functions in each of these workspaces.
Component files provide an efficient and easy-to-use method to store APL variables (of any type, shape, and size) in a file, and read them into the workspace when they are needed. Each individual item in the file is known as a component. A single number may constitute one component, while a matrix containing several thousand numbers may be its next door neighbour.
Functions, operators and classes can also be stored in component files, but they must first be converted into character arrays by the system function
APLX supports two different component file systems. The first is based on system functions such as
The second of these is based on the file-access primitives
For more information, see the separate section on Component File Systems.
'Native' files are operating-system files which are not necessarily associated with APL, and which are typically used for exchanging data with non-APL applications. For example, they might include text files, HTML pages, or binary files produced by a Fortran application. Unlike component files (which retain information about the type and shape of APL data), the structure of native files is unknown to APLX, so you as the programmer are responsible for specifying how the data should be interpreted. For example, you can specify that you want to read the first four bytes of a file as an integer, and the next 32 bytes as a character vector.
See the section on Native File Functions for details.
System Functions for Data Import/Export
Although native files provide a general, low-level way to exchange data with other applications, there are a number of common file formats for which APLX provides an easier alternative, by means of the
Accessing Database Records
Much of the data in modern computer systems, especially for large commercial applications with many thousands of records, is held in relational databases. These are accessed and updated using SQL ('Structured Query Language'). You can easily interface to such databases by using the
In addition to the above facilities for directly reading and writing data into the APL workspace, APLX provides a number of System Classes which can manipulate specific types of files such as images and movies. See the documentation on the Picture, Movie, Image classes in the separate manual System Classes and User-Interface Programming.
Copyright © 1996-2010 MicroAPL Ltd