24.02.2012, 12:53
(
Последний раз редактировалось Padarom; 24.02.2012 в 13:25.
)
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:
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:
Hope you can help me.
They are created as followed:
Regards
Padarom
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");
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Я ...
They are created as followed:
pawn Код:
reporter=%s\nsubject=%s\nreason=%s\ndescription=%s\ntime=%s\nread=1
Padarom