I am stuck.  I have followed along with the "Simple Database"
contained in the Rebol how-to.html file, but I can't manipulate
the header object that save/header load/header creates.
I want to make changes and save the data back, with the header intact.

Here's what I have been trying out:

1. I started by copying some data into Rebol 
(its from the how-to.html):

cities: [
  "Ukiah" CA 95482 
  "Richmond" VA 12345 
  "Omaha" NE 43210 
  "New York" NY 20202 
]

2. I saved it with a header added
save/header %cities1.r cities [
   Title: "City data"
   User_Groups: "PDX Vanc"
   ]

The cities1.r file looks like this:

REBOL [
    Title: "City data" 
    User_Groups: "PDX Vanc"
]

"Ukiah" CA 95482 
"Richmond" VA 12345 
"Omaha" NE 43210 
"New York" NY 20202


3. I then loaded the file with header 
cities1: load/header  %cities1.r

4. Testing header and data shows everything is there:
header: first cities1
data: next cities1

a. inspect header
probe first header
[self Title Date Name Version File Home Author Owner Rights
Needs Tabs Usage Purpose Comment History Language User_groups]
probe header/Title
"City data"
probe header/User_groups
"PDX Vanc"

b. inspect data items
probe data
[
    "Ukiah" CA 95482
    "Richmond" VA 12345
    "Omaha" NE 43210
    "New York" NY 20202]

5. Now I change something in the data:

change find data 12345 99999
probe data
[
    "Ukiah" CA 95482
    "Richmond" VA 99999
    "Omaha" NE 43210
    "New York" NY 20202]

6. ---------- Here's where I am stuck ---------
How can I save the data with the header information?

7. I tried a simple save:
save %cities2.r cities1

cities2.r looks like this:

make object! [
    Title: "City data"
    Date: none
    Name: none
    Version: none
    File: none
    Home: none
    Author: none
    Owner: none
    Rights: none
    Needs: none
    Tabs: none
    Usage: none
    Purpose: none
    Comment: none
    History: none
    Language: none
    User_Groups: "PDX Vanc"
] 
"Ukiah" CA 95482 
"Richmond" VA 12345 
"Omaha" NE 43210 
"New York" NY 20202

Attempting load/header results in ERROR

cities2: load/header  %cities2.r
** Syntax Error: Script is missing a REBOL header.
** Where: cities2: load/header %cities2.r

load without refinement loses the header info, or
at least puts it in a different part under cities2

cities2: load  %cities2.r
== [
    make object! [
        Title: "City data"
        Date: none
        Name: none
        Version: none
        File: no...

but:
>> header2: first cities2
== make
>> probe first header2
** Script Error: first expected series argument of type: series
 pair event money date object port time tuple any-function libr
ary struct event.
** Where: probe first header2

8. Save/header with only one argument is ERROR:
save/header %cities3.r cities1
** Script Error: save expected header-data argument of type: bl
ock object.
** Where: save/header %cities3.r cities1

9. save/header *almost* works:
save/header %cities3.r data header 

buts adds words 'make object! after REBOL
thusly:

REBOL 
make object! [
    Title: "City data"
    Date: none
    Name: none
    Version: none
    File: none
    Home: none
    Author: none
    Owner: none
    Rights: none
    Needs: none
    Tabs: none
    Usage: none
    Purpose: none
    Comment: none
    History: none
    Language: none
    User_Groups: "PDX Vanc"
]

"Ukiah" CA 95482 
"Richmond" VA 12345 
"Omaha" NE 43210 
"New York" NY 20202

---
I cannot find information about
converting objects into blocks etc,
or how to reach the values of object keys.

Thanks.

doug edmunds
6 April 2000

________________________________________________________________
YOU'RE PAYING TOO MUCH FOR THE INTERNET!
Juno now offers FREE Internet Access!
Try it today - there's no risk!  For your FREE software, visit:
http://dl.www.juno.com/get/tagj.

Reply via email to