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

[REBOL] Re: Variable not avilable out of a foreach

From: tim-johnsons::web::com at: 10-Dec-2007 11:48

On Monday 10 December 2007, Tim Johnson wrote:
> On Monday 10 December 2007, Giuseppe Chillemi wrote: > > I have the following script: > > > > rebol: [] > > get_data: does [ > > parse line [] > > ] > > > > main_loop: does [ > > file_database: request-file > > database: read/lines to-file file_database > > foreach line database [ > > get_data > > ] > > ] > > main_loop > > > > The script returns LINE has no Value, I must assign it to a temporary > > variable... why ? > > try changing get_data to a func and pass 'line as an argument to it > tim
p.s. your problem stems from the way that rebol evaluates 'get_data before the loop and knows nothing about a global 'line. Just for grins, you could also put get_data as a 'does inside the loop where 'line would now be in the same scope as 'get_data. as in: b: [1 2 3 4 5] foreach line b[g: does[print line] g] but is probably not a good idea.... :-) tj