fread - read lines with time gap
#4

Quote:
Originally Posted by ranme15
Посмотреть сообщение
That doesn't help considering I will have to start reading from a specific line which is basically impossible.
I have alot of lines to read and it takes some time to read & put some actions on each line within one step.
https://sampwiki.blast.hk/wiki/Fseek

A more simplier way is to open the file outside the timer function and pass the file handle to read timer. Then you close the file when it is completely read (i.e fread returns 0)
Doing so, you won't have to open&seek&close the file at every timer call.


Pseudo code example:
Код:
ProcessFile(filename[], interval)
{
    new File: handle = fopen(filename, io_read);
    if(handle) SetTimerEx("ReadLines", interval, 0, "dd", handle, interval);
}

ReadLines(File: handle, interval)
{
    new string[128];
    if(fread(handle, string))
    {
        // do whatever

        SetTimerEx("ReadLines", interval, 0, "dd", handle, interval); // continue reading
    }
    else // nothing left unread
    {
        fclose(handle);
    }
}
Reply


Messages In This Thread
fread - read lines with time gap - by ranme15 - 16.09.2016, 21:42
Re: fread - read lines with time gap - by Nero_3D - 16.09.2016, 21:52
Re: fread - read lines with time gap - by ranme15 - 16.09.2016, 21:59
Re: fread - read lines with time gap - by Spmn - 16.09.2016, 22:37
Re: fread - read lines with time gap - by PrawkC - 16.09.2016, 23:12
Re: fread - read lines with time gap - by ranme15 - 16.09.2016, 23:18

Forum Jump:


Users browsing this thread: 1 Guest(s)