How to save objects in a file ?
[1/9] from: etienne:alaurent:free at: 21-Aug-2001 3:48
Hi, rebolers,
I want to save objects and/or blocks of objects in a file.
What is the simplest way do this ?
---
Etienne
[2/9] from: brett:codeconscious at: 21-Aug-2001 12:35
How about something like this:
o1: context [description: "i am an object" date: now/date]
o2: context [description: "i am an object too" date: now/date]
objects: reduce [o1 o2]
save %objects.r objects
loaded-objects: reduce load %objects.r
print loaded-objects/1/description
Brett.
[3/9] from: coussement:c:js:mil:be at: 21-Aug-2001 9:37
Salut Etienne,
Depending of what you're intending to do, pick one of the two methods:
1. save %object-file.r my-object
2. write %object-file.r mold my-object
The advantage of the second method is that you can use the multiple
refinements of the _write_ function as in:
write/append %object-file.r mold my-object
Hope this helps,
christophe
[4/9] from: etienne:alaurent:free at: 21-Aug-2001 15:27
Hi Brett and Christophe
Christophe wrote :
>Depending of what you're intending to do, pick one of the two methods:
>
>1. save %object-file.r my-object
>2. write %object-file.r mold my-object
>
>The advantage of the second method is that you can use the multiple
>refinements of the _write_ function as in:
>
>write/append %object-file.r mold my-object
and Brett wrote :
>How about something like this:
>o1: context [description: "i am an object" date: now/date]
<<quoted lines omitted: 3>>
>loaded-objects: reduce load %objects.r
>print loaded-objects/1/description
It doesn't run !
My code is like this :
===============================
obj1: make object! [
data1: copy "string 1"
data2: copy "string 2"
]
obj2: make object! [
data3: copy "string 3"
data4: copy []
]
obj3: make obj1 []
obj4: make obj1 []
append tail obj2/data4 "object3"
append tail obj2/data4 obj3
append tail obj2/data4 "object4"
append tail obj2/data4 obj3
save %objects.r obj2
=================================
and at the time of the save execution, the app is frozen. Why ? what is the
solution ?
Cheers
---
Etienne
[5/9] from: cyphre:volny:cz at: 21-Aug-2001 16:19
Hi Etienne,
If I understand well, first you should remove the 'tail command from the
last 4 lines of your code since 'append appends a value to the tail of a
series itself.
Have fun!
Cyphre
---- Original Message -----
[6/9] from: arolls:bigpond:au at: 22-Aug-2001 0:22
I executed this code ok.
I was able to save before and after
each of the appends below.
Does it work in a new rebol?
Could it be something else about
your situation?
[7/9] from: coussement:c:js:mil:be at: 22-Aug-2001 9:00
Hi Etienne:
> > obj1: make object! [
> data1: copy "string 1"
<<quoted lines omitted: 12>>
> save %objects.r obj2
> =================================
[
Just tried your code. It works fine to me ...
Perhaps some kind of access right problem or unavailability of one
of another network drive ?
Did you try this in _home_ or _my documents_ local directory ?
Regards,
Christophe
]
[8/9] from: etienne:alaurent:free at: 22-Aug-2001 13:58
Hi, Christophe, Anton, and the others ...
Sorry, I made a mistake in my code. So I corrected it, and now it's ok.
Thank you for your help :-)
---
Etienne
[9/9] from: john:thousand-hills at: 23-Aug-2001 21:10
-- Unable to decode HTML file!! --
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted