From: Mauricio Kishi Date: 2006-12-22T11:24:41+09:00 Subject: Weird error while reading binary files Hello everyone! I just started messing around with Ruby and so far it's been great. Somehow I've stepped into some weird error I can't understand nor solve it.. I've been trying to google about it but with no results.. Here's what's going on: I've got a file structure which is like: 4 bytes - Number of entries For number of entries : 300 bytes of information.. several integers, longs, floats, strings... If I do: theFile = File.open('FilePath') infoArray = Array.new infoEntries = theFile.read(4).unpack('V')[0] infoEntries.times do |i| infoArray[i] = theFile.read(300).unpack('VA4V2FS4V12A24A8A32A32A32A32A32V8') end It will go fine until infoArray[33]. After that it won't work at all! Let me make myself clear: irb(main):002:0> theFile = File.open('FILEPATH') => # irb(main):003:0> theFile.pos = 10244 => 10244 irb(main):004:0> theFile.read(4) => "H\001\000\000" irb(main):005:0> theFile.pos => 14340 irb(main):006:0> See how it jumped positions?! That's odd.. Is there a file-size limit or something like that? I'm under Windows, by the way... -- Posted via http://www.ruby-forum.com/.