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

[REBOL] problems with series of objects Re:

From: ingo:2b1 at: 13-Aug-2000 22:01

Hi Raimund, I'll step to your program, and maybe we'll find out together ... Once upon a time [raimund--swol--de] spoketh thus:
> I try to have a series of self defined objects and pick one of the objects to > access it. > > Here is the code I use: > > REBOL [] > > book: make object! [ > author: > title: > info: none > ]
REBOL> help book object with fields: author (none) none title (none) none info (none) none
> book1: make book [] > book1/author: "Fritz the Cat" > book1/title: "That is the title of book1" > book1/info: "That is info of book1"
REBOL> help book1 object with fields: author (string) "Fritz the Cat" title (string) "That is the title of book1" info (string) "That is info of book1" Up to now, it seems ok.
> book2: make book [] > book2/author: "Fritz the Cat" > book2/title: "That is the title of book2" > book2/info: "That is info of book2" > > my-serie: [book1 book2]
REBOL> help my-serie MY-SERIE is a block of value: [book1 book2] You might get uneasy here, let's see what follows.
> this-book: make book [] > > this-book: first my-serie
REBOL> help this-book THIS-BOOK is a word of value: book1 Ahhh, yes. You see, your block contains words, that by pure coincidence have the same name as your objects, but that doesn't mean that they are bound to the same values. To get your "objects" into your block, you have to reduce it, like REBOL> my-serie: reduce [book1 book2] REBOL> help my-serie MY-SERIE is a block of value: [ make object! [ author: "Fritz the Cat" title: "That is the title of book1" info: "That is info of book1" ] make object! [ author: "Fritz the Cat" title: "That is the title of book2" info: "That is info of book2" ]] REBOL> this-book: first my-serie REBOL> print this-book/info That is info of book1 I hope this helps Ingo PS: Don't assume your help will give you as much info as you've seen here. This is my patched version ...