Hi all,

As a part of a larger project I'm currently trying to read in a file or unknown length comprised of a lot of ints separated by line breaks. I'd like to read each int into an array. I'd like to use ReadFile from the irvine32 library but I see that it only reads into a buffer and I'm also confused as to if it will handle a file of variable length (since it requires a number of bytes to read). Any help or clarification with reading in line by line into an array with a file or variable length?

Posted on 2009-04-29 14:00:03 by 66replica
Simply read until there is no further data..?
Posted on 2009-04-29 15:30:43 by ti_mo_n
Ok, I can read the whole file into a buffer using an Irinve32 library function but I need to parse the data by line break into an array and also be able to take a different path when I encounter a blank line. Sorry, I'm not super proficient with assembly.
Posted on 2009-05-01 17:13:37 by 66replica
You need to read up on simple tokenizing, like for expression calculators or pre-compilers. As you read in your integers, strip out the EOL sequences, if you hit two EOL sequences back to back that's a blank line, You have two options, take your alternate action right then, or save a secondary array containing the index of where blank lines where and then when you begin reading your integer array you can check the second array's contents for the current index to see if it's flagged for the alternate execution path.

A better way would be to save your file as a binary file, dump your integers directly into the file (without separators) as binary data. Then when you read it in, just read them as integers into memory directly and access them as an integer array (no parsing of the end of line sequence needed).

Implementation of this is solely up to you. I just thought I would give you a bump in a possible direction.
Posted on 2009-05-03 13:11:14 by Synfire
Thanks for the direction. I'll give it a shot this afternoon.
Posted on 2009-05-04 10:46:12 by 66replica