Thamm, Russell wrote:
Direct Access Files
There appears to be some discrepancy between record numbering for reading and writing. To read record n, I specify SeekRead(n). But to write record n, I specify SeekWrite(n).
Thanks for the report. I fixed the bug. (Just wait for the next version.)
But two comments about your test program. You declare a file [0..5], but then seek to 6. I don't think that's really OK, is it? (But GPC accepts it, at least currently. This might be due to the missing range checking, and would not work anymore when range checking will be implemented.)
You terminate the file name with a chr (0). That's not only unnecessary (because the Name field of BindingType is a Pascal string, not a CString), but also potentially problematic: the run time system (RTS) uses libc routines internally to open the file. Those use CStrings, and therefore regard the #0 as a terminator. But perhaps the RTS does some other things with the file name, treating it as a Pascal string, and counting the #0 as part of the name (AFAIK, it doesn't do so currently, but it might do later, when parts of it are translated into Pascal).
Frank