Quote:Original post by Buckeye
If Delphi is like the old Turbo Pascal I used to use, there is a lot of run-time type checking to keep things "safe" for you. That may be the problem. But it shouldn't be really slow.
When you say it gets "stuck," do you mean it loops indefinitely and you have to kill the program? If so, you may have to check for EOF after each Read and Readln.
This article does something like you're doing. You may want to take a look at it.
EDIT: You have to handle lines that don't begin with a recognized character. OBJ files allow comment lines, blank lines, etc.
For instance, if you have a comment line in your OBJ file:Read(F,letter); // read in "/"if( letter='..') // readlnelse if( letter='..' // readln
then you won't read and throw away the comment line. The next time you Read(F,letter) it will be just the next character in the comment line.
That may why it's so slow. If you have a line that doesn't begin with v, f, n or t you read the entire line character by character.
Your "if, else if" sequence must account for all possibilities.
I don't think it's looping indefinitely, because i'v created a new project and created a text file with 9 v letters and 9 numbers like that:
v 1v 2v 3v 4v 5v 6v 7v 8v 9
And it doesn't get stuck, everythings okay, works perfect. When i'v tried reading obj format file, it get's stuck, i think that's because there are many simbols there.
EDIT: I don't think that there is switch statment in Delphi
[Edited by - SuBXaX on July 11, 2010 9:33:44 AM]