aboutsummaryrefslogtreecommitdiff
path: root/src/hyper/pages/LIB.ht
blob: e14b397c9fb19031d8e4d6708ec4a32c1771002c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved.
% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk.
\newcommand{\LibraryXmpTitle}{Library}
\newcommand{\LibraryXmpNumber}{9.41}
%
% =====================================================================
\begin{page}{LibraryXmpPage}{9.41 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}
%