[REBOL] Antwort: Re: Object "Serialization"
From: sharriff:aina:med-iq at: 23-Feb-2001 6:35
Great script Renaud! this would do till RT builds in Object serialisation
into REBOL or someone writes a module/ Library..
Regards
Sharriff Aina
"Renaud"
<[rgombert--esse] An: <[rebol-list--rebol--com]>
ntiel.net> Kopie:
Gesendet von: Thema: [REBOL] Re: Object "Serialization"
[rebol-bounce--r]
ebol.com
22.02.01 23:39
Bitte
antworten an
rebol-list
Maybe this script could be of some help. It's intended to allow to save and
retrieve a word/value pair in a file.
It is an early version i've made while learning REBOL.
An example : I put the script in the word 'file, then save this word, give
it another value then reload the initial one.
the scipt is 845 bytes long, and the disk data only 443.
Any comment welcome
Renaud
-----------------------------------------------------------------
sample session for the example:
-----------------------------------------------------------------
>> file: read %scripts/binutils.r
== {REBOL [
Title: "Nom du script"
File: %binutils.r
Date: 4-Jun-1999
Author: "Renaud GOMBERT"
Purpose: "Save...
>> put-bin file %data.bin
>> file: 456
== 456
>> file
== 456
>> get-bin %data.bin
== {REBOL [
Title: "Nom du script"
File: %binutils.r
Date: 4-Jun-1999
Author: "Renaud GOMBERT"
Purpose: "Save...
>> file
== {REBOL [
Title: "Nom du script"
File: %binutils.r
Date: 4-Jun-1999
Author: "Renaud GOMBERT"
Purpose: "Save...
>>
-----------------------------------------------------------------
The scipt itself:
-----------------------------------------------------------------
REBOL [
Title: "Nom du script"
File: %binutils.r
Date: 4-Jun-1999
Author: "Renaud GOMBERT"
Purpose: "Save and retrieve any word/value pair as binary"
To-do: {
Make a refinement to do compressions only if needed
Allow processing of multiple word/value pairs at one time
}
Release: 0.0.1
Category: []
]
put-bin: func [ "Save word/value pair as compressed binary"
'data [any-type!] "word to process"
filename [file!] "file to write to"
/local temp
][
temp: make object! [
value: get data
name: data
]
write/binary filename compress to-binary mold temp
]
get-bin: func [ "Save word/value pair as compressed binary"
filename [file!] "file to get word/value from"
/local temp
][
temp: do decompress read/binary filename
set temp/name temp/value
]