% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk.
\newcommand{\LibraryXmpTitle}{Library}
\newcommand{\LibraryXmpNumber}{9.45}
%
% =====================================================================
\begin{page}{LibraryXmpPage}{9.45 Library}
% =====================================================================
\beginscroll

%
%
%
%
%



The \spadtype{Library} domain provides a simple way to store \Language{}
values in a file.
This domain is similar to \spadtype{KeyedAccessFile} but fewer declarations
are needed and items of different types can be saved together in the same
file.

\xtc{
To create a library, you supply a file name.
}{
\spadpaste{stuff := library "/tmp/Neat.stuff" \bound{stuff}}
}
\xtc{
Now values can be saved by key in the file.
The keys should be mnemonic, just as the field names are for records.
They can be given either as strings or symbols.
}{
\spadpaste{stuff.int    := 32^2     \free{stuff}\bound{stuffa}}
}
\xtc{
}{
\spadpaste{stuff."poly" := x^2 + 1  \free{stuffa}\bound{stuffb}}
}
\xtc{
}{
\spadpaste{stuff.str    := "Hello"   \free{stuffb}\bound{stuffc}}
}
\xtc{
You obtain
the set of available keys using the \spadfunFrom{keys}{Library} operation.
}{
\spadpaste{keys stuff \free{stuffa,stuffb,stuffc}\bound{stuffabc}}
}
\xtc{
You extract values  by giving the desired key in this way.
}{
\spadpaste{stuff.poly     \free{stuffb}}
}
\xtc{
}{
\spadpaste{stuff("poly")  \free{stuffb}}
}
\noOutputXtc{
When the file is no longer needed, you should remove it from the
file system.
}{
\spadpaste{)system rm -rf /tmp/Neat.stuff  \free{stuff}\bound{rmstuff}}
}

For more information on related topics, see
\downlink{`File'}{FileXmpPage}\ignore{File},
\downlink{`TextFile'}{TextFileXmpPage}\ignore{TextFile}, and
\downlink{`KeyedAccessFile'}{KeyedAccessFileXmpPage}\ignore{KeyedAccessFile}.
\showBlurb{Library}
\endscroll
\autobuttons
\end{page}
%
