![]() |
![]() |
|
Component Files |
|
This section discusses component files, which are used as a very easy way to store and retrieve APL data in a proprietary format. APLX is also able to access other types of files (e.g. text and pictures) via a number of system functions. For example, see:
Note: APLX supports two different component file systems. The first of these is based on the file-access primitives The second is based on system functions such as APL was originally implemented without a filing system because for simple purposes the facilities provided by the workspace are quite sufficient. In general you can keep all the data you need in the current workspace with occasional 'imports' from a saved workspace. However, occasionally 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 wouldn't want to replicate the functions in each of these workspaces. You could get round this by having the functions in the active workspace and using APLX has a very flexible and simple filing system available for such situations. FilesAPLX files are identified by number rather than by name. Any integer can be used. An APL file can be regarded as a series of numbered pigeon-holes with the useful feature that (subject to space being available) each pigeon hole can hold as much or as little as you like. ComponentsThe pigeon-holes are called components. A single letter of the alphabet may constitute one component while a matrix containing several thousand numbers may be its next door neighbour. Functions can be stored in files as well, but they must first be converted into character-matrices by the system function Basic file operationsCreating a file is simply a matter of writing a component to it. The command for this is TABLE ⍈ 3 1 The above command puts the contents of Here's another example: PRICES ⍈ 3 2 The information held in Reading data from a file follows the same principles. To get component 1 from file 3 you would type: ⍇ 3 1 In the form shown, the command It's more likely that you'll want to put the data into a variable and carry out some operation on it. The following statement reads component 2 from file 3 and assigns it to a variable called A ← ⍇ 3 2 Deleting a component or file is specified in much the same way using a command ⍗ 3 2 deletes component 2 from file 3, renumbering components in the same way lines in a function are renumbered after deleting a line. Similarly, components can be inserted by writing to a number that lies 'between' two components: PRICES ⍈ 3 1.5 The last example, will write a component containing the information in For a fuller explanation of reading and writing component files, see 'Component File Systems' in the APLX Language Manual.
|
Copyright © 1996-2008 MicroAPL Ltd