Each roll-over in File?

D

Don Wilde

[Note: parts of this message were removed to make it a legal post.]

fellow, Rubyists:

I have the following code in a PDF writer using Prawn on Ruby 1.8.7 p249
(Default on Ubuntu 10.04). My problem is that the

@src_file.each do | line |
...
end

... block appears to be rolling over and repeating lines from the beginning
of the file. I tried to use p330 but due to Debian's known ...
eccentricities... it won't load my ruby gems.

@src_file = File.open @src_fn
Prawn::Document.generate( @out_fn ) do | pdf |
@next = true
@src_file.each do | line |
while @lines_to_do < 1 do
update_state_n_format( pdf )
@next = true if @lines_to_do <= 0
end
process_line( line, pdf )
@lines_to_do -= 1
end
@src_file.close
end

Is this a known issue? Or already fixed?
--
-- Don Wilde
ph: 512-394-8896 skype: donwilde1
e: (e-mail address removed)
"If you are creative and add value to the world, sleep well. You've earned
it."
 
A

Aaron D. Gifford

... block appears to be rolling over and repeating lines from the beginni= ng
of the file. ...
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0@src_file.each do | line |
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0while @lines_to_do= < 1 do
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0update_sta= te_n_format( pdf )
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0@next =3D = true if @lines_to_do <=3D 0
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0end
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0process_line( line= , pdf )
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0@lines_to_do -=3D = 1
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0end
...

Are you positive that nothing in update_state_n_format() or
process_line() is touching @src_file and perhaps rewinding the file's
read position?

Wondering,
Aaron out.
 
D

Don Wilde

[Note: parts of this message were removed to make it a legal post.]

...


[snip]


Are you positive that nothing in update_state_n_format() or
process_line() is touching @src_file and perhaps rewinding the file's
read position?

I did figure it out. Above this code is a line that says

close if @done == true

... the close being a wxRuby close(), and it was actually coming back from
the close() and re-opening the file and crashing before the close()
completed all its operations at the Wx level.

Changing it to

if @done == true then
close
else
# parse the file
end

...worked.

In other words, close() != die() :D

--
-- Don Wilde
ph: 512-394-8896 skype: donwilde1
e: (e-mail address removed)
"If you are creative and add value to the world, sleep well. You've earned
it."
 

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

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top