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

[REBOL] Re: Setting argument values in objects

From: greggirwin:mindspring at: 5-Nov-2001 9:29

Hi Thorsten, Hopefully I understand your need correctly. If so, this might work. A short time ago, Ammon Johnson cooked up a nifty way to *get* a value from an object given a path. I just made a quick mod to set the value and it worked in the one test I ran. :) Here is his original and my modified version (which you would use to set the value). Let me know if it works. I left the print statements in so you can see what it generates to do its job. ; Ammon Johnson's function get-path-obj: func [str[string!] /local return-val][ return-val: copy [] tmp-val: parse str "/" insert/dup tail return-val [get in] ((length? tmp-val) - 1) append return-val [get] foreach val tmp-val [ append return-val compose [(to-lit-word :val)] ] print form return-val return do compose return-val ] ;-- SET version of GET-path-obj. (Gregg Irwin) set-path-obj: func [str[string!] value /local return-val][ return-val: copy [] tmp-val: parse str "/" insert/dup tail return-val [get in] ((length? tmp-val) - 1) append return-val [get] foreach val tmp-val [ append return-val compose [(to-lit-word :val)] ] change return-val [set] ; change first 'get to 'set append return-val value ; 'set takes the value print form return-val return do compose return-val ] HTH! --Gregg