SA-MP Forums Archive
File Functions in PAWN - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: File Functions in PAWN (/showthread.php?tid=406298)



File Functions in PAWN - nestyx - 09.01.2013

hi everyone hope someone can help me with this Filesystem?

Destination: Extract a String at a specific position from a File.

I can't find the procedure for this?

PS: If it's possible i don't really want to read in the whole file cause it costs speed.

(If there doesn't exist such a function.
For example, how can I read line 3 From a Textfile in PAWN in an easy way?)


Re: File Functions in PAWN - LarzI - 09.01.2013

Do you use the default file functions? If so, you can use a while loop to only read one line at a time, then break the loop when you find the line you want.


Re: File Functions in PAWN - nestyx - 09.01.2013

You mean I could just change the while-loop for a for-loop counting to 3 and break it?


Re: File Functions in PAWN - LarzI - 09.01.2013

Not really, no. The way you'll read one line at a time, you'll need to use it this way
pawn Code:
while( fread( file ))
So to do what you want, you'll have to declare a variable before the loop and increase it. For example:
pawn Code:
new
    i;
while( fread( file ))
{
    if( i == 2 )
    {
        //3th line is reached (i = 0 - line 1, i = 1, line 2 etc.)
    }
    i ++;
}



Re: File Functions in PAWN - nestyx - 09.01.2013

Thanks It's so simple. (First thinking than asking, sry)
thanks it works.