Counting files and creating a new
#2

Can't realy help unless we know what file system you use, for the native file functions (or most other file systems), you could do something simalar to this,
pawn Код:
new fcount;//global
#define MAX_FILES 50

for(new i = 1; i < MAX_FILES; i++)//note i initialised at 1 because thats what it said in ur post,
{                                 //if you have "0.ini" change it.
    new
        str[12];       
    format(str, 12, "%d.ini", i);
    if(fexist(str))
        fcount++;
    else
        break;
}
Now you can use "fcount" it will hold the number of the last file. To create a new one add one to its value, and use that result - as a name for the file. You could also put that in a function make "fcount" local to the function and use it as a return value.
Reply


Messages In This Thread
Counting files and creating a new - by Pooh7 - 20.12.2010, 08:12
Re: Counting files and creating a new - by iggy1 - 20.12.2010, 08:35
Re: Counting files and creating a new - by Pooh7 - 20.12.2010, 09:01
Re: Counting files and creating a new - by iggy1 - 20.12.2010, 09:06

Forum Jump:


Users browsing this thread: 1 Guest(s)