By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!Does FILESEEKL accept a negative line number when moving relative to the current line? ... seems not.
Does @FILESEEKL relative to the current line work at all? Below, the file is ordered by IP range, and after I echo lines 10000 and 10001 and %@fileseekl[handle,1,1] I get the second line of the file! I was expecting line 10003.
v:\> set h=%@fileopen[IpToCountry.csv,r]
v:\> set seek=%@fileseekl[%h,10000]
v:\> echo %@fileread[%h]
1170456576,1170472959,US
v:\> echo %@fileread[%h]
1170472960,1170481151,CA
v:\> set seek=%@fileseekl[%h,1,1]
v:\> echo %@fileread[%h]
16777216,16777471,AU <=== that's the second line of the file!
v:\> set h=%@fileopen[abc.txt,r]
v:\> set seek=%@fileseekl[%h,3]
v:\> echo %@fileread[%h]
d
v:\> echo %@fileread[%h]
e
v:\> set seek=%@fileseekl[%h,1,1]
v:\> echo %@fileread[%h]
g
v:\> do i=0 to 100000 ( echo %i >> 0-100000.txt )
v:\> set h=%@fileopen[0-100000.txt,r]
v:\> set seek=%@fileseekl[%h,50000]
v:\> echo %@fileread[%h]
50000
v:\> echo %@fileread[%h]
50001
v:\> set seek=%@fileseekl[%h,1,1]
v:\> echo %@fileread[%h]
1
v:\> do f in /l abc.txt seektest.txt ( type %f & echo. & set h=%@fileopen[%f,r]
& set seek=%@fileseekl[%h,5] & echo line 5: %@fileread[%h] & set seek=%@fileseekl[%h,1,1]
& echo line ?: %@fileread[%h] & echo. & set h=%@fileclose[%h] )
0
1
2
3
4
5
6
7
8
9
x
line 5: 5
line ?: 7
0
1
2
3
4
5
6
7
8
9
10
line 5: 5
line ?: 1
Here's a self-contained one:
Now that you say that, my later observations don't seem so mysterious. It seemed to work/not work depending on the parity of the file size (or something like that).Fixed for the next build. (The Unicode check was skewing the file read position.)