From: James Herdman Date: 2009-04-23T01:09:09+09:00 Subject: Re: JRuby problem --00163616413ba8a1da046826fbe0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit My guess is that the context fails to keep track of local variables. Try an experiment with something simpler: ScriptContext sct = jruby.getContext jruby.eval("name = 'Ahmed'") jruby.eval('puts "My name is #{name}"') If things explode, my theory is correct. James PS: Semi-colons aren't required, nor are empty parenthesis. It's considered out of the Ruby norm to use them. As such, I'd avoid them in your coding. See http://www.pathf.com/blogs/ruby-and-rails-style-guide/ On Wed, Apr 22, 2009 at 11:45 AM, Ahmed Abdelsalam wrote: > Hi,... > > I'm trying to execute the following lines: > > ScriptContext sct = jruby.getContext(); > jruby.eval("sheet = Spreadsheet.new", sct); > jruby.eval("sheet.cells.a1 = 'Welcome'", sct); > > The first two lines are executed correctly, but the last one gives the > following error: > undefined local variable or method `sheet' for main:Object > > it indicates that sheet is undefined although it's defined in line 2. > > When I try to execute both commands in a single statement like: > jruby.eval("sheet = Spreadsheet.new \n sheet.cells.a1 = 'Welcome'", > sct); > > The statement is executed correctly. > > Please help > > Regards,... > > Ahmed > -- > Posted via http://www.ruby-forum.com/. > > --00163616413ba8a1da046826fbe0--