mIRC Home    About    Download    Register    News    Help

Print Thread
#47332 05/09/03 06:00 AM
Joined: Jan 2003
Posts: 52
L
Babel fish
OP Offline
Babel fish
L
Joined: Jan 2003
Posts: 52
.line returns line the file pointer is currently at
.pos returns position of the file pointer

#47333 05/09/03 08:28 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
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.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#47334 05/09/03 09:40 AM
Joined: Feb 2003
Posts: 2,810
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,810
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.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
#47335 05/09/03 02:12 PM
Joined: Jan 2003
Posts: 52
L
Babel fish
OP Offline
Babel fish
L
Joined: Jan 2003
Posts: 52
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.

#47336 05/09/03 03:20 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
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.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Link Copied to Clipboard