SA-MP Forums Archive
Error 079! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Error 079! (/showthread.php?tid=658142)



[SOLVED]: Error 079! - bgedition - 24.08.2018

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.


Re: Error 079! - Lokii - 24.08.2018

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;




Re: Error 079! - bgedition - 24.08.2018

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


Re: Error 079! - Spmn - 24.08.2018

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.


Re: Error 079! - bgedition - 24.08.2018

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.