Sorry... a few errors in the "comments" inside the script and the lack of
indentation (due to outlook conersion of tabs to spaces), so I repost the
script:


REBOL [
    Title: "Nom du script"
    File:  %binutils.r
    Date:  22-Feb-2001
    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  [ "Load word/value pair from a compressed binary"
      filename [file!] "file to get word/value from"
      /local temp
][
      temp: do decompress read/binary filename
      set temp/name temp/value
]

Renaud GOMBERT
email : [EMAIL PROTECTED]
ICQ# 2602184

----- Original Message -----
From: "Renaud" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, February 23, 2001 12:39 AM
Subject: [REBOL] Re: Object "Serialization"


> 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
> ]
>
> --------------------------------------------------------------------------
--
> ----
>
> ----- Original Message -----
> From: "GS Jones" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, February 22, 2001 11:32 PM
> Subject: [REBOL] Re: Object "Serialization"
>
>
> > > > > In a separate thread, a question was asked about serialization of
> > > > > objects by Sharriff Aina.  I had a similar question in mind and
> > was
> > > > > hoping for an answer.  Since the thread had gotten a bit off
> > topic,
> > > I'm
> > > > > reposting essentially the same question in this separate thread.
> > > > >
> > > > > To date, when I want to save an object, I've been using 'save.
> > Then
> > > > > when I need the object back, I use 'read and then 'do the object.
> > > > >
> > > > > For example:
> > > > >
> > > > > data: make object! [
> > > > >     name: "Joe"
> > > > > ]
> > > > >
> > > > > save %my-object.r data
> > > > >
> > > > > ;... later i need the object ...
> > > > > data: read %my-object.r
> > > > > data: do data
> > > > > print data/name
> > > >
> > > > use 'load instead of 'read? Then you don't need to 'do the 'data ...
> > > > -pekr-
> > >
> > > Thanks, that is a good point!
> > > Scott
> >
> > Actually, when I tried it, simply using 'load did not re-initialize the
> > object (unless I am missing some additional subtle point).  I played
> > with several additional variations, with the same conclusions.  So I
> > guess the way I've been doing it will have to be good enough.  It still
> > seems as though there should be a more seemless and coherent way to
> > serialize the object.
> >
> > Thanks for your attention, pekr.
> > --Scott
> >
> > --
> > To unsubscribe from this list, please send an email to
> > [EMAIL PROTECTED] with "unsubscribe" in the
> > subject, without the quotes.
> >
> >
>

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to