Re: It seems simple...
- Posted by Sabal Mike <MikeS at NOTATIONS.COM> Dec 13, 2000
- 447 views
>From library.doc Seek (move) to any byte position in the file fn or to the end of file if i2 is -1. For each open file there is a current byt= e position that is updated as a result of I/O operations on t= he file. The initial file position is 0 for files opened for r= ead, write or update. The initial position is the end of file fo= r files opened for append. The value returned by seek() is 0 = if the seek was successful, and non-zero if it was unsuccessful. I= t is possible to seek past the end of a file. In this case undef= ined bytes will be added to the file to make it long enough for = the seek. =AF assumes fn is already defined and opened atom fpos fpos =3D seek(fn,-1) if fpos=3D0 then fpos=3Dwhere(fn) fpos=3Dseek(fn,fpos-127) end if =AF assuming both seeks were successful, you are now 128 bytes prior to t= he end of the file. Michael J. Sabal >>> impee3 at EXCITE.COM 12/13/00 01:11PM >>> I'm trying to open a binary file for read only, go to the last 128 bytes = in the file, and read that string. Seems simple, right? I'm at the point whe= re I can't find an equivalent Euphoria routine that I'd use if I were writin= g this in VB. In VB, I'd use -- FileLen(FileName) - 127 -- to do what I'm trying. I tried to use get_bytes, but to no avail. Can anybody send me a snippet of code that'll do what I need? Seek() would work fine for moving the placement of the next reading to 12= 8 bytes from the end of the file, but getting the actual length of the file= is where I'm stuck. Thanks, Brian