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 one by assigning
null to it, close the file, and then remove the file.
i1 : filename = temporaryFileName () | ".dbm"
o1 = /tmp/M2-29252-1.dbm
|
i2 : x = openDatabaseOut filename
o2 = /tmp/M2-29252-1.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)
first
second
|
i7 : x#"second" = null
|
i8 : scanKeys(x,print)
first
|
i9 : close x
o9 = 0
|
i10 : removeFile filename
|