[REBOL] Re: Antwort: Re: Object "Serialization"
From: rgombert:essentiel at: 23-Feb-2001 9:54
----- Original Message -----
From: <[Sharriff--Aina--med-iq--de]>
To: <[rebol-list--rebol--com]>
Sent: Friday, February 23, 2001 7:35 AM
Subject: [REBOL] Antwort: Re: Object "Serialization"
> Great script Renaud! this would do till RT builds in Object serialisation
> into REBOL or someone writes a module/ Library..
Thanks...
Here is the second version, wich can proceed with individual words or word
list. This script need more basic error checking (file existence, etc...)
but as i do not have yet a really deep understanding of REBOL, maybee some
of the wizards here may find some deeper hidden potential problem.
Renaud
ICQ# 2602184
REBOL [
Title: "Word/Value pair(s) binary saver"
File: %binutils.r
Date: 22-Feb-2001
Author: "Renaud GOMBERT"
Email: [rgombert--essentiel--net]
Purpose: "Save and retrieve any word/value pair(s) in binary files"
To-do: {
Make a refinement to do compression only if needed
}
Done: {
Allow processing of multiple word/value pairs at one time
}
Release: 0.1.0
Category: []
]
put-bin: func [ "Save word/value pair(s) as compressed binary"
'data [word! block!] "word or word list to process"
filename [file!] "file to write to"
/local temp
][
temp: make object! [
value: copy []
name: copy []
]
either (type? data) = word! [
temp/value: get data
temp/name: data
][
foreach item data [
append/only temp/value get item
append temp/name make lit-word! item
]
]
write/binary filename compress to-binary mold temp
]
get-bin: func [ "Load word/value pair(s) from a compressed binary"
filename [file!] "file to get word/value from"
/local temp i
][
temp: do decompress read/binary filename
either (type? temp/name) = word! [
set temp/name temp/value
][
i: 1
foreach item temp/value [
set temp/name/:i item
i: i + 1
]
]
]