Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!samsung!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.fortran Subject: Re: File Handling in Fortran 77 Message-ID: <3657@goanna.cs.rmit.oz.au> Date: 2 Sep 90 05:37:11 GMT References: <56017@iuvax.cs.indiana.edu> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 48 In article <56017@iuvax.cs.indiana.edu>, bomgard@copper.ucs.indiana.edu (Tim Bomgardner) writes: > c Position the file pointer. Only C's SEEK_SET (beginning of file) is > c implemented. No error checking is performed. > c > integer function fseek(lun, offset, whence) > integer lun, offset, whence > common /cio/ fileptr > integer fileptr > > fileptr = 0 > fseek = 0 > return > end This is always equivalent to rewind(), which is hardly what we were expecting! A slightly better implementation would be integer function fseek(lun, offset, whence) integer lun, offset, whence integer filpos common /cio/ filpos integer temp if (whence .eq. 0) then C absolute positioning temp = offset else if (whence .eq. 1) then C relative positioning temp = filpos + offset else C relative to end (not supported) or invalid temp = -1 end if if (temp .ge. 0) then filpos = temp fseek = 0 else C error fseek = -1 end if return end On the other hand, aren't records numbered from 1? The cleanest way to handle that would be in getc() and putc(). -- You can lie with statistics ... but not to a statistician.