[File]: Reading all lines?
#1

Hi, I've just a simple question for a simple little thing. Is it possible to read and print all lines from a file?
I use currently DINI, it would be really nice if someone give an example...
Reply
#2

i suggest u use y_ini cuz it can read all lines of files at once and much faster than dini
https://sampforum.blast.hk/showthread.php?tid=175565
Reply
#3

if you look in dini.inc there is lots of examples of how to read a file or use file function
im a but rusty with it but i gutted dini_get to make this quickly
should print eack line of the file to the console (untested)
pawn Код:
public printfile(filename[]){
    new File:fohnd;
    new tmpres[MAX_STRING];
    fohnd=fopen(filename,io_read);//open file
    if (!fohnd) return 0;              //end if dosent exist
    while (fread(fohnd,tmpres)) { //read each line
        print(tmpres); //print line
    }
    fclose(fohnd);//close file
    return 1;
}
hope that helps
Reply
#4

What do you mean?
Reply
#5

Quote:
Originally Posted by (SF)Noobanatior
Посмотреть сообщение
if you look in dini.inc there is lots of examples of how to read a file or use file function
im a but rusty with it but i gutted dini_get to make this quickly
should print eack line of the file to the console (untested)
pawn Код:
public printfile(filename[]){
    new File:fohnd;
    new tmpres[MAX_STRING];
    fohnd=fopen(filename,io_read);//open file
    if (!fohnd) return 0;              //end if dosent exist
    while (fread(fohnd,tmpres)) { //read each line
        print(tmpres); //print line
    }
    fclose(fohnd);//close file
    return 1;
}
hope that helps
This helped me alot, thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)