How to bind to foreach context ?

Posted by Rebol Tutorial on Stack Overflow See other posts from Stack Overflow or by Rebol Tutorial
Published on 2010-05-05T18:15:21Z Indexed on 2010/05/05 18:18 UTC
Read the original article Hit count: 177

Filed under:

Currently I have this snippet of code:

save-blocks: func[file /local f out][
    foreach [field1 field2 field3 field4 field5 field6 field7 field8 field9] blocks [

out: copy ""
repeat n 9 [
  part: get bind to-word rejoin ["field" n] 'field1 
  out: rejoin [out part ";"]
]
        remove back tail out
        write/lines/append f out


]

It's not generic enough, I'd like to pass this

block: [field1 field2 field3 field4 field5 field6 field7 field8 field9]

as parameter and write something like this:

save-blocks: func[block file /local f out][
    foreach block blocks [

out: copy ""
repeat n 9 [
  part: get bind to-word rejoin ["field" n] 'field1 
  out: rejoin [out part ";"]
]
        remove back tail out
        write/lines/append f out


]

But I don't know how to bind in this case too hard for me :(

© Stack Overflow or respective owner

Related posts about rebol