[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Newbie - Q: working with files

Allison Newman

7/20/2006 8:38:00 AM

Hi,

I have a function with the following code

def first_parse
@in_file.each_line do |line|
puts line
@line += 1;
tokens = line.split
handle_command(tokens, line)
end
puts "End of file reached"
@heap.dump(@obj_file)
end

The problem is that I parse the entire file (@in_file), and my app
exits, but I never execute the puts "End of file reached". Anyone have
any ideas why?

--
Posted via http://www.ruby-....

2 Answers

Mat Schaffer

7/20/2006 12:43:00 PM

0

On Jul 20, 2006, at 4:37 AM, Allison Newman wrote:
> Hi,
>
> I have a function with the following code
>
> def first_parse
> @in_file.each_line do |line|
> puts line
> @line += 1;
> tokens = line.split
> handle_command(tokens, line)
> end
> puts "End of file reached"
> @heap.dump(@obj_file)
> end
>
> The problem is that I parse the entire file (@in_file), and my app
> exits, but I never execute the puts "End of file reached". Anyone
> have
> any ideas why?

I would wonder if something's happening in handle_command. Or maybe
there's an output buffering problem going on. You could try
'$stdout.sync = true'. But this is all just blind guessing.
-Mat

Tait Pollard

7/20/2006 5:25:00 PM

0

> handle_command(tokens, line)
> end
> puts "End of file reached"
> @heap.dump(@obj_file)
> end
>
> The problem is that I parse the entire file (@in_file), and my app
> exits, but I never execute the puts "End of file reached". Anyone have
> any ideas why?

Maybe something is going wrong in your handle_command call that makes
the program exit without finishing. Make sure you are running ruby with
warnings on and that might help a little.

Tait Pollard


--
Posted via http://www.ruby-....