Hi Tim,

The function your are looking for is net-utils/export
This will return all values in the object that have a value.

result: net-utils/export system/options/cgi

if you want a list of 'none as well use this modified version
(I just commented out the value? test of the original net-utils/export)

result: export2 system/options/cgi

export2: func [
    {Export an object to something that looks like a header}
    object [object!] "Object to export"
    /local words values result word
][
    words: next first object
    values: next second object
    result: make string! (20 * length? words)
    foreach word words [
       ; if found? first values [
            insert tail result reduce [word ": " first values newline]
       ; ]
        values: next values
    ]
    result
]


And here are some other ways to play with object words and values

> cgi-labels: ["Server Software" "Server Name"]

cgi-label: next first system/options/cgi

== [server-software server-name gateway-interface server-protocol
server-port request-method
 path-info path-translated script-name ...

values: next second system/options/cgi
== [none none none none none none none none none none none none none none
none none none []]


Cheers

Allen K


----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, April 18, 2000 4:49 AM
Subject: [REBOL] [REBOL] Traversing object values


> Given an object:
>
> let's use system/options/cgi
>
> I would like to traverse the object
> and print out the values only, each preceded by
> a custom label.
>
> I know that to use print mold system/options/cgi
> will dump the object. But I want to
> just extract the values and concatenate them
> with a customized label.
>
> So that instead of
> make object! [
>     server-software: none
>     server-name: none
>     gateway-interface: none
>     server-protocol: none
>     server-port: none
>     request-method: none
>     path-info: none
>     path-translated: none
>     script-name: none
>     query-string: none
>     remote-host: none
>     remote-addr: none
>     auth-type: none
>     remote-user: none
>     remote-ident: none
>     Content-Type: none
>     content-length: none
>     other-headers: []
> ]
> I will have:
>
>     Server Software:  none
>     Server Name: none
>     ; etc......
>
> I believe that I will also need to code a block like
> cgi-labels: ["Server Software" "Server Name"]

cgi-label: next first system/options/cgi

== [server-software server-name gateway-interface server-protocol
server-port request-method
 path-info path-translated script-name ...

values: next second system/options/cgi
== [none none none none none none none none none none none none none none
none none none []]


>
> and iterate simultaneously through the object and
> the block.
>
> Will give a nice professional looking "dump" of
> the cgi environment, and will also edify me on
> the process of interating blocks and objects.
>
> Thanks in advance
> Tim
>
>

Reply via email to