[REBOL] Re: Object Database
From: carl:rebol at: 9-Apr-2001 8:28
What!? You just want us to just whip out an object database, eh? ;)
Ok, why not.... Here is a small "contacts" database keyed by email.
You can expand or reduce the record definition without corrupting
or affecting the database.
REBOL [Title: "Email Contact Database"]
record: context [name: email: phone: web: none]
load-data: has [data] [
data: load/all db-file
foreach item blk [
item: make record item
repend database [item/email item]
save-data: has [data] [
data: copy 
foreach [key obj] database [
append/only data third obj
save db-file data
find-data: func [email] [select database email]
remove-data: func [email] [remove/part find database email 2]
insert-data: func [email' name' phone' web'] [
repend database [
make record [
You can expand/contract the record definition at any time.
This is untested... but should be close to working, less a few
minor typos. If you expect to grow this database to a large
size, you will want to MAKE HASH! the database when you load
PS: The remove/part on find really does work. Remove none is
allowed in Core 2.5.