From string to object
[1/6] from: sanghabum::aol::com at: 25-Nov-2001 19:02
Hi all, I'm having a bit of trouble getting from a string to the contents of the object that the string names. I've tried an embarrassing combinations of 'set and 'load and wotnot, without finding the right magic. Can anyone help, please? An example to try to make sense of what I am asking .... ======= fred: make object! [field1: 1 field2: 2] Doris: make object! [field1: 3 field2: 4] userdata: ask "Which object?" print mold :userdata ========= What should the 'Print statement be to print object Fred if the user types fred ? Thanks! Colin.
[2/6] from: larry:ecotope at: 25-Nov-2001 16:39
Hi Colin, You almost had it. Look at this:
>> fred: make object! [f1: 1] >> userdata: ask "Which object? "
Which object? fred == "fred"
>> print mold to-word userdata
>> print mold get to-word userdata
make object! [ f1: 1 ]
[3/6] from: john_kenyon:mlc:au at: 26-Nov-2001 13:27
Hi Colin, How about, print mold get to-word userdata You can always do something like the following to retrieve specific values, x: get to-word userdata get in x 'field1 get in x 'field2 Which is the same as, get in x to-word "field1" Cheers, John
[4/6] from: rebol665:ifrance at: 26-Nov-2001 8:57
Hi This is what I have experimented on the console. HTH
>> test: get to-word userdata >> probe test
make object! [ field1: 1 field2: 2 ] Patrick
[5/6] from: sanghabum:aol at: 26-Nov-2001 6:16
> I'm having a bit of trouble getting from a string to the > contents of the object that the string names. I've tried > an embarrassing combinations of 'set and 'load and > wotnot, without finding the right magi
Thanks to everyone who replied. I'd gone word blind late at night, and that tiny word 'get had vanished from my vocabulary. This list is so devastating useful that I'm surprised Microsoft doesn't buy it up and bundle a bloated, broken, version in the next IE release <g> --Colin.
[6/6] from: greggirwin:mindspring at: 26-Nov-2001 11:15
Hi Colin, << This list is so devastating useful that I'm surprised Microsoft doesn't buy it up and bundle a bloated, broken, version in the next IE release <g> >> That's what their MVP program is. It started out when a small number of VB supporters spent all their free time answering questions in the old CompuServe MSBASIC forum. Some of the support guys from MS wanted to say Thanks! and offered the title of "MVP" (along with a plaque, and various and sundry items). Over the years it spread to other MS products and grew enormously. --Gregg