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

[REBOL] how to bind to a local variable

From: alberto:origen:mx at: 10-Oct-2008 10:08

Hi, I'm struggling with the next problem, I made a small function I use to replace variables inside a string: rep-vars: func [str /local var beg end] [ parse str [ some [ to ":" beg: ":" copy var to ":" ":" end: ( var: to-word var change/part beg get var end ) ] to end ] ] this function let me replace variables inside a string:
>> var1: "here" >> var2: "there" >> str: "some vars :var1: and some vars :var2:" >> rep-vars str >> probe str
== "some vars here and some vars there" what I need to solve is the function only works with global variables, but of course not from a function using locals: new-func: func [/local lvar lstr] [ lvar: "locally" lstr: "a var used :lvar:" rep-vars lstr ;; ERROR ] May be the solution is the bind function but I don't get how any ideas? BTW, I never before has used the bind function, so I'm an absolute beginner in "bindology"! cheers - Alberto C