Newbie - Q: working with files

A

Allison Newman

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?
 
M

Mat Schaffer

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
 
T

Tait Pollard

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top