Computer Science Canada attempt to read past eof error |
Author: | cloust [ Sun Jan 29, 2006 9:17 am ] | ||
Post subject: | attempt to read past eof error | ||
in my program, you can create an account, edit it, login, etc. I was trying to make a search function in the program, where you can lookup your account without having to login. I can succesfully look up the first account in my record, but if I try to lookup anything else, I get an error saying that it attempted to read past eof, and I have no idea why its doing this. here is the code, I was wondering if anyone could see what I'm missing.
|
Author: | Delos [ Sun Jan 29, 2006 9:36 am ] | ||
Post subject: | |||
You've read the 'end of file' (eof). Make sure your source file has the correct number of lines (1 for each of the get: statements). Additionally, you may want to edit your code a bit and try incorporate this sort of routine instead:
The 'exit when eof (file)' is the key line. See if you can figure out how to incorporate that into your code (hint, you'll only be using 1 get: statement). |
Author: | cloust [ Sun Jan 29, 2006 10:03 am ] |
Post subject: | |
well, after trying the method you showed, I realised that turing was writing the input to my files wrong. if, say for my phone number, I put (812) 888 3456, it would write each item after the space to a new line. I have no idea why its doing that. |
Author: | Delos [ Sun Jan 29, 2006 11:11 am ] |
Post subject: | |
Sounds familiar. Post the code for that part of your proggie, I'll take a look at it. |
Author: | cloust [ Sun Jan 29, 2006 11:21 am ] | ||
Post subject: | |||
|
Author: | Delos [ Sun Jan 29, 2006 1:02 pm ] |
Post subject: | |
Hmm...strange. I just tried out your code and it works fine for me. (I did have to recreate the pertinent undeclared variables though...). I noticed that you're using seek and mod - these are more commonly used with write: as opposed to put:. It does its job though. You may want to consider, instead of using them, to read the whole file into a flexy array, get the new info, then put: all of that to the file. Technically a little slower, but might solve your problem (which for some reason doesn't happen to me). |
Author: | cloust [ Sun Jan 29, 2006 2:07 pm ] |
Post subject: | |
okie, I found the tutorial on flexible arrays, so I'll see what I can do. thanks for the help! |
Author: | redrenagade [ Sat Feb 04, 2006 6:17 pm ] |
Post subject: | |
This might help, try to put the "exit when eof" line at the end of your loop. I think your program is exiting when it reaches the end of file, then, for some reason, trying to read the next line of code within the loop. |