fread problems
#1

Hello,
I've written a small function which reads a .txt file line by line. Depending on the text in this line the value should be saved in a specific variable.
That's the code:
pawn Код:
do
{
    i++;
    exists = true;
    format(path, 68, "/%s/%i.txt", dini_path, i);
    if(fexist(path))
    {
        ID[count] = i;
        count++;
        new File:report = fopen(path, io_read);
        while(fread(report, string))
        {
            if(strfind(string, "subject", true) != -1) { strdel(string, 0, 8); subject = string; }
            if(strfind(string, "time", true) != -1) { strdel(string, 0, 5); date = string; }
            if(strfind(string, "reason", true) != -1) { strdel(string, 0, 7); reason = string; }
            if(strfind(string, "read", true) != -1) { strdel(string, 0, 5); read = strval(string); }
            if(read) format(cat, 68, "{ED9E15}%s {FFFFFF}\t%s: %s\n", date, subject, reason);
            else format(cat, 68,"{ED9E15}%s {ED1515}\t%s: %s\n", date, subject, reason);
            strcat(msg, cat);
        }
        fclose(report);
    }
}
while(i<50);
if(!exists) return ShowPlayerDialog(playerid, 104, DIALOG_STYLE_MSGBOX, "Beschwerden", "Es sind aktuell keine Beschwerden eingetragen.", "Okay", "Nicht okay");
ShowPlayerDialog(playerid, 104, DIALOG_STYLE_LIST, "Beschwerden", msg, "Auswдhlen", "Abbrechen");
However, when I type in my command, the following dialog appears:

My guess certainly would be, that I mistyped the strdel at the start- and endingplace what from a new line would be formatted into the string. But I'm unable to see where the problem is.

The .txt file is built up in the following way:
Код:
reporter=Padarom
subject=Mike
reason=RegelverstoЯ
...
Hope you can help me.
They are created as followed:
pawn Код:
reporter=%s\nsubject=%s\nreason=%s\ndescription=%s\ntime=%s\nread=1
Regards
Padarom
Reply


Messages In This Thread
fread problems - by Padarom - 24.02.2012, 12:53
AW: fread problems - by Padarom - 24.02.2012, 13:57
AW: fread problems - by Padarom - 24.02.2012, 15:23
AW: fread problems - by Padarom - 24.02.2012, 15:39
AW: fread problems - by Padarom - 24.02.2012, 16:04
AW: fread problems - by Padarom - 24.02.2012, 17:38

Forum Jump:


Users browsing this thread: 1 Guest(s)