Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Object "Serialization"

From: rgombert:essentiel at: 23-Feb-2001 0:39

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 ]