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

Iteration over object "properties"

 [1/5] from: kpeters:otaksoft at: 29-Feb-2008 12:55


Am not sure if I am using the proper terminology here, so please bear with me: How do I iterate over the "properties" of an object? o: make object! [ p1: "Berlin" p2: "Germany" p3: 3'400'000 ] I want to get at the "property names" in string form as in "p1" "p2" and so forth Thanks for any help, as always Kai

 [2/5] from: compkarori:g:mail at: 29-Feb-2008 21:44


>> o: make object! [ p1: "Berlin" p2: "Germany" p3: 3'400'000 ] >> first o
== [self p1 p2 p3] On Sat, Mar 1, 2008 at 9:55 AM, Kai Peters <kpeters-otaksoft.com> wrote:
> Am not sure if I am using the proper terminology here, so please bear with > me:
<<quoted lines omitted: 7>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- Graham Chiu http://www.synapsedirect.com Synapse - the use from anywhere EMR.

 [3/5] from: petr:krenzelok:seznam:cz at: 29-Feb-2008 22:07


Hi, do you mean something like following?: ->> blk: next first o == [p1 p2 p3] ->> foreach word blk [print get in o word] Berlin Germany 3400000 Cheers, Petr Kai Peters napsal(a):

 [4/5] from: carl::cybercraft::co::nz at: 29-Feb-2008 21:44


On Friday, 29-February-2008 at 12:55:01 Kai Peters wrote,
>Am not sure if I am using the proper terminology here, so please bear with > me:
<<quoted lines omitted: 4>>
>Thanks for any help, as always >> first o
== [self p1 p2 p3]
>> second o
== [make object! [ p1: "Berlin" p2: "Germany" p3: 3400000 ] "Berlin" "Germany" 3400000]
>> third o
== [p1: "Berlin" p2: "Germany" p3: 3400000]
>> foreach [word value] third o [probe value]
Berlin Germany 3400000 == 3400000 That help? -- Carl Read.

 [5/5] from: dhsunanda::gmail::com at: 28-Feb-2008 13:17


Kai:
> How do I iterate over the "properties" of an object?
In addition to the other replies: if you need the field names too: o: make object! [ p1: "Berlin" p2: "Germany" p3: 3'400'000 ] foreach word next first o [ print [word " = " get in o word] ]
> p1 = Berlin > p2 = Germany > p3 = 3400000
Sunanda

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted