Thread overview
Read a text file in any position.
Jan 18, 2019
Giovanni Di Maria
Jan 18, 2019
bauss
Jan 18, 2019
Giovanni Di Maria
January 18, 2019
Hi All
I have a text file like this:

111111
222222
333333
444444
555555
666666
777777
......

I execute these functions:

i = archive.readln();
i = archive.readln();
i = archive.readln();
i = archive.readln();

so "i" is 444444.

Is there a method to move the pointer of file to beginning of file or to any position (for example back to 2nd row), without to close the file?

Thank you very much.
Regards
Giovanni





January 18, 2019
On Friday, 18 January 2019 at 08:10:25 UTC, Giovanni Di Maria wrote:
> Hi All
> I have a text file like this:
>
> 111111
> 222222
> 333333
> 444444
> 555555
> 666666
> 777777
> ......
>
> I execute these functions:
>
> i = archive.readln();
> i = archive.readln();
> i = archive.readln();
> i = archive.readln();
>
> so "i" is 444444.
>
> Is there a method to move the pointer of file to beginning of file or to any position (for example back to 2nd row), without to close the file?
>
> Thank you very much.
> Regards
> Giovanni

Use File (https://dlang.org/library/std/stdio/file.html)

And seek() (https://dlang.org/library/std/stdio/file.seek.html)

And then one of its read functions.

rawRead will let you read the raw bytes at the position.
January 18, 2019
On Friday, 18 January 2019 at 08:49:08 UTC, bauss wrote:
> On Friday, 18 January 2019 at 08:10:25 UTC, Giovanni Di Maria wrote:
>> Hi All
>> I have a text file like this:
>>
>> 111111
>> 222222
>> 333333
>> 444444
>> 555555
>> 666666
>> 777777
>> ......
>>
>> I execute these functions:
>>
>> i = archive.readln();
>> i = archive.readln();
>> i = archive.readln();
>> i = archive.readln();
>>
>> so "i" is 444444.
>>
>> Is there a method to move the pointer of file to beginning of file or to any position (for example back to 2nd row), without to close the file?
>>
>> Thank you very much.
>> Regards
>> Giovanni
>
> Use File (https://dlang.org/library/std/stdio/file.html)
>
> And seek() (https://dlang.org/library/std/stdio/file.seek.html)
>
> And then one of its read functions.
>
> rawRead will let you read the raw bytes at the position.




Thank you very very much.
Giovanni