Error 079!
#1

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;
}
EDIT: Man, how stupid am I?
FIX:
Quote:
Originally Posted by Spmn
Посмотреть сообщение
Move `Locale` definition below, so `ParseFile` is defined before the call. Looks like a compiler bug.
Michael.
Reply
#2

Quote:
Originally Posted by bgedition
Посмотреть сообщение
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;
}
Michael.
You forgot one bracket!

heres the fix

PHP код:
Locale(Code[]) {
    return 
ParseFile(LocaleFileCodePARSE_KEYStrue);
}
ParseFile(File:FileSearch[], Type PARSE_KEYSbool:IgnoreCase falseDelimiter[] = "=") {
    new 
Line[2048 3], Key[1024], Value[1024], Format[24];
    
format(Formatsizeof(Format), "p<%s>s[%i]s[%i]"Delimiter10241024);
    while(
fread(FileLine)) {
        if(!
sscanf(LineFormatKeyValue)) {
            
strtrim(Key); strtrim(Value);
            if(!
strcmp(Type == PARSE_KEYS Key ValueSearchIgnoreCase)) {
                
Line Type == PARSE_KEYS Value Key;
                break;
            }
        }
    }
    }
    return 
Line;

Reply
#3

Quote:
Originally Posted by Lokii
Посмотреть сообщение
You forgot one bracket!
heres the fix
No, I did not. Please look again at the code!
Reply
#4

Move `Locale` definition below, so `ParseFile` is defined before the call. Looks like a compiler bug.

Anyway, returning strings is bad practice. You should use references.
Reply
#5

Quote:
Originally Posted by Spmn
Посмотреть сообщение
Move `Locale` definition below, so `ParseFile` is defined before the call. Looks like a compiler bug.

Anyway, returning strings is bad practice. You should use references.
Thank you, I forgot that definition matters. Will consider references.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)