Description
A database file is just like a hash table, except both the keys and values have to be strings. In this example we create a database file, store a few entries, remove an entry with
remove, close the file, and then remove the file.
i1 : filename = temporaryFileName () | ".dbm"
o1 = /tmp/M2-1930102-0/0.dbm
|
i2 : x = openDatabaseOut filename
o2 = /tmp/M2-1930102-0/0.dbm
o2 : Database
|
i3 : x#"first" = "hi there"
o3 = hi there
|
i4 : x#"first"
o4 = hi there
|
i5 : x#"second" = "ho there"
o5 = ho there
|
i6 : scanKeys(x,print)
second
first
|
i7 : remove(x,"second")
|
i8 : scanKeys(x,print)
first
|
i9 : close x
o9 = 0
|
i10 : removeFile filename
|