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

[REBOL] Re: IOS data

From: allenk:powerup:au at: 2-Oct-2001 23:19

----- Original Message ----- From: "Petr Krenzelok" <[Petr--Krenzelok--trz--cz]> To: <[rebol-list--rebol--com]> Sent: Tuesday, October 02, 2001 7:55 PM Subject: [REBOL] Re: IOS data
> > > > Hi, > > > So I propose to start with a collection of descriptions for those
objects, so
> > that we all can base our work on these discriptions. It should even be
> > to handle different versions of those objects, as Rebol supports checks
> > the presense of words in objects. > > How? > > value? obj/word ??? If word doesn't exist, it fails ... or - in obj
'word? Here is an example from a couple of apps that share data. Each of the apps has slightly extended a msg obj. (Note: This is from express beta, and not necessarily representative of the new IOS framework) 1. Presumably you know which features or fields in the data your app supports. So you create a template object for the data, complete with default values (in this case I set all to none). msg-obj: context [fx: who: when: color: content: file: group: none] 2. the data is a simple block (which could be loaded from a file) [who: "Allen" when: 2-Oct-2001/22:54:47+10:00 color: 200.100.50 file: %msg0001.r group: "support" offset: 0x0 refresh: 1:00:00 content: "Test Messgage"] 3. Make our object if error? try [msg: make msg-obj load data][msg: make msg-obj []] make object! [ fx: none who: "Allen" when: 2-Oct-2001/22:54:47+10:00 color: 200.100.50 content: "Test Message" file: %msg0001.r group: "support" offset: 0x0 refresh: 1:00 ] (Note how compact and extensible the REBOL block format is compared to XML for transfering simple data.) 4. Now I can use the parameters of the object that my script knows about. I can ignore the paremeters that I don't know about. And I can test for ones I expect because of my defaults in the template. if msg/fx [do really amazing fx stuff] if msg/who [print ["Msg for " msg/who] 5. You can also find out if other words are present in the object,
>> found? in msg 'color
== true
>> found? in msg 'squid
== false 5. If I wanted to save this msg object I would use save msg-file third msg Cheers, Allen K