mIRC Homepage
Posted By: lordares $fseek(name | N) - 05/09/03 06:00 AM
.line returns line the file pointer is currently at
.pos returns position of the file pointer
Posted By: qwerty Re: $fseek(name | N) - 05/09/03 08:28 AM
Regarding .pos, use $fopen(name|N).pos, it's the same thing.

As for the .line property, mirc would have to count and keep track of all the $crlf's in the file (until the current .pos) to get the line number. Apart from having a significant impact in performance, I'm not even sure it could work correctly, since counting the $crlf's would mean moving the read pointer around behind your back.
Posted By: Raccoon Re: $fseek(name | N) - 05/09/03 09:40 AM
I'd like to see it count crlfs up to .pos on demand, store that info, and keep track of subsequently read crlfs as needed.

Though, would mean creating an array and storing every crlf's absolute or relative .pos in the file. The only problem is this array's integrity when you start writing to the file, removing lines or simply writing over crlfs... it would mean having to completly rehash that array using any number of methods to calculate new values depending on how the file was altered... short of just re-reading the entire file again.

It would be difficult, indeed.
Posted By: lordares Re: $fseek(name | N) - 05/09/03 02:12 PM
Oh, neat. :P
(Don't see how I overlooked that)

As for line counting, it would be very possible for each -param that is givne to /fseek, but using /fseek for position would arise the problem in counting $crlf.

He is using C, It wouldn't be too hard for him to have an integer counting \r\n up to the point the file pointer is at, even though /fseek -w may *jump* to a certain place in the file, the entire file is still being read, each line. Not with moving position though which does create a problem ;/

I would like to see this feature, but now that I really think about it, the C code might not allow this to happen too easily.
Posted By: qwerty Re: $fseek(name | N) - 05/09/03 03:20 PM
Quote:
...but using /fseek for position would arise the problem in counting $crlf.


Exactly. If /fseek is used without switches, mirc does not count the crlf's, it just jumps to position N, so $fseek().line could only work after a /fseek with -l, -w and -r (-n could -should- be an exception; to jump to the next line, mirc doesn't need to keep track of any previous crlf's in the file) but on an important condition: that /fseek started scanning from the beginning of the file. Consider this example:
Code:
...
fseek blah 1234
fseek -w blah *mirc*
Even though /fseek -w was called, $fseek().line cannot be calculated because /fseek -w started seeking from the 1234th byte in the file, so it doesn't know the number of lines before that point.
© mIRC Discussion Forums