Dyalog Primer - Files - Component Files
Explorationtie←'c:\dick\temp\ccc.dycf' ⎕fcreate 0
(3 4⍴⍳12) ⎕fappend tie
'abcdef' ⎕fappend tie
(3 4⍴⊂3 4⍴⊂3 4⍴⍳12)⎕fappend tie
'c:\dick\temp\ccc.dycf' ⎕fstie 33
⍬ ⎕freplace 33 2
files are as old as APL itself, hence some archaisms of syntax.
default filename extension is 'dcf', which conflicts with Microsoft
- Tie numbers may be specified, or
you can let APL generate one.
- Component numbers
start at 1 (regardless of what you may prefer for your index origin).
may contain any APL variable, and - just like in the workspace, any new
value can replace any old value.
- Component files
grow until you force a resize, when unused space is reclaimed.
other APLs also have component files, and the same syntax to handle
them, you can't use them directly - the internal formats are
- Despite their historic anachronisms,
problems of accessing them from other programming languages, component
files "just work" and are a good choice for holding data values that
you know are only going to be used by your APL applications.
conventions with component files include...
the purpose of the file in component 1.
the component structure in component 2.
a number of empty (unused) components between component 2 and the first
"data" component - so that you have some convenient space available
when your file design changes.
- System Functions (Dyalog Language Reference)...
⎕FAPPEND ⎕FAVAIL ⎕FCREATE ⎕FDROP ⎕FERASE ⎕FHOLD ⎕FLIB ⎕FNAMES
⎕FNUMS ⎕FRDAC ⎕FRDCI ⎕FREAD ⎕FRENAME ⎕FREPLACE ⎕FRESIZE ⎕FSIZE
⎕FSTAC ⎕FSTIE ⎕FTIE ⎕FUNTIE
- APL Files (Dyalog Users Guide Chapter 3)
- ComponentFile class in supplied workspace samples/OO4APL (to get a perspective on how the system functions can be used/recast into an object-oriented context.
a function to report the number of components in a file, the size and
timestamp of last update of each component, and the overall size of the
file (in bytes).
- Write a function to compact a component file - returning both old a new sizes.
a simple text file with a number of paragraphs (separate the paragraphs
with a blank line). Write a function which reads this native file
and creates a new component file containing one component for each
paragraph. If there already is a component file with this name it
should be replaced by the new file.
component numbers is obtuse. Design a component file (and associated
read/write) functions that will let you access components by name.
often need to set component content to "null" (the associated data no
longer existing) - when new components are needed it's tidier if these
dead components can be reused rather than have new data always appended
as new components at the end of the file. Design a component
(and associated read/write/delete functions) that let you keep a list
of redundant components for reuse.