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

[REBOL] Re: How do I dynamically modify an object?

From: edanaii:cox at: 14-Jan-2003 15:46

Andrew Martin wrote:
>Ed wrote: > >>Using the examples from the REBOL On-line dictionary: >> >> Example: Make Object! [ Name: "Fred" Age: 5000000 ] >> >> Get in Example 'Name >>== "Fred" >> >> Set in Example 'Name "Fred Flintstone" >>== "Fred Flintstone" >> >>How do I dynamically add to example, after it has been created, Address: >> >> >"123 Bedrock Path". > >>I tried using 'Set, 'Make and a couple other functions, but they didn't >> >> >work. I was probably using them wrong. :) > >Rebol unfortunately doesn't allow objects to be expanded. However you can >expand block! values. For example: > >>>Example: [ Name "Fred" Age 5000000 ] >>> >>> >== [Name "Fred" Age 5000000] > >>>repend Example ['Address "123 Bedrock Path"] >>> >>> >== [Name "Fred" Age 5000000 Address "123 Bedrock Path"] > >>>example/name >>> >>> >== "Fred" > >>>example/address >>> >>> >== "123 Bedrock Path" >
That's what finally I realized. My final solution is to do this:
>> x: {Address: "Bedrock Central" Phone: "Just shout loudly!" }
== {Address: "Bedrock Central" Phone: "Just shout loudly!" }
>> Contact: Make Example to-block x >> Probe Contact
make object! [ Name: "Fred Flintstone" Age: 35000000 Address: "Bedrock Central" Phone: "Just shout loudly!" ] That certainly gets the job done... -- Sincerely, | The Traveller awaits the morning tide. He doesn't Ed Dana | know what's on the other side. But something deep Software Developer | inside of him keeps telling him to go. He hasn't 1Ghz Athlon Amiga | found a reason to say no. | -- the Alan Parsons Project, Days are Numbers. =========== http://OurWorld.CompuServe.com/Homepages/EDanaII ===========