24.08.2018, 18:22
Quote:
Hello!
It's been long time since I used to code in pawn and I've forgotten things. I searched throughout G00gle and I've found nothing on my issue. So I have compiler error 079: inconsistent return types (array & non-array). Now I know that the function 'ParseFile' is returning something else than a string, but I cannot find it. Код:
Locale(Code[]) { return ParseFile(LocaleFile, Code, PARSE_KEYS, true); } ParseFile(File:File, Search[], Type = PARSE_KEYS, bool:IgnoreCase = false, Delimiter[] = "=") { new Line[2048 + 3], Key[1024], Value[1024], Format[24]; format(Format, sizeof(Format), "p<%s>s[%i]s[%i]", Delimiter, 1024, 1024); while(fread(File, Line)) { if(!sscanf(Line, Format, Key, Value)) { strtrim(Key); strtrim(Value); if(!strcmp(Type == PARSE_KEYS ? Key : Value, Search, IgnoreCase)) { Line = Type == PARSE_KEYS ? Value : Key; break; } } } //TODO: Fix error 079 return Line; } |
heres the fix
PHP код:
Locale(Code[]) {
return ParseFile(LocaleFile, Code, PARSE_KEYS, true);
}
ParseFile(File:File, Search[], Type = PARSE_KEYS, bool:IgnoreCase = false, Delimiter[] = "=") {
new Line[2048 + 3], Key[1024], Value[1024], Format[24];
format(Format, sizeof(Format), "p<%s>s[%i]s[%i]", Delimiter, 1024, 1024);
while(fread(File, Line)) {
if(!sscanf(Line, Format, Key, Value)) {
strtrim(Key); strtrim(Value);
if(!strcmp(Type == PARSE_KEYS ? Key : Value, Search, IgnoreCase)) {
Line = Type == PARSE_KEYS ? Value : Key;
break;
}
}
}
}
return Line;
}