SA-MP Forums Archive
local variable "result" shadows a variable at a preceding level - 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: local variable "result" shadows a variable at a preceding level (/showthread.php?tid=414272)



local variable "result" shadows a variable at a preceding level - Fiore - 08.02.2013

C:\Users\Fiore\Desktop\NIKOlikeAboss\pawno\include \dutils.inc(383) : warning 219: local variable "result" shadows a variable at a preceding level
C:\Users\Fiore\Desktop\NIKOlikeAboss\gamemodes\woo tisidiot.pwn(7481) : warning 219: local variable "result" shadows a variable at a preceding level
C:\Users\Fiore\Desktop\NIKOlikeAboss\gamemodes\woo tisidiot.pwn(7491) : error 025: function heading differs from prototype
C:\Users\Fiore\Desktop\NIKOlikeAboss\gamemodes\woo tisidiot.pwn(7791) : warning 219: local variable "result" shadows a variable at a preceding level

1) What's wrong with dutils.inc? LOL
2) Can you please help me to fix those errors/warning?

pawn Код:
stock strrest(const string[], index)
{
    new length = strlen(string);

    new offset = index;
    new result[256]; // 7481
    while ((index < length) && ((index - offset) < (sizeof(result) - 1)) && (string[index] > '\r'))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
pawn Код:
stock IsNumeric(const string[]) // 7491
{
    if(strlen(string) > 15) return 0;
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return 0;
    }
    return 1;
}
pawn Код:
mystrtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }

    new offset = index;
    new result[32]; // 7791
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}



Re : local variable "result" shadows a variable at a preceding level - yusei - 08.02.2013

PHP код:
stock strrest(const string[], index)
{
    new 
length strlen(string);
    new 
offset index;
    new 
result2[256]; // 7481
    
while ((index length) && ((index offset) < (sizeof(result2) - 1)) && (string[index] > '\r'))
    {
        
result2[index offset] = string[index];
        
index++;
    }
    
result2[index offset] = EOS;
    return 
result2;
}
stock IsNumeric(const string2[]) // 7491
{
    if(
strlen(string2) > 15) return 0;
    for (new 
0strlen(string2); ji++)
    {
        if (
string2[i] > '9' || string2[i] < '0') return 0;
    }
    return 
1;
}
mystrtok(const string[], &index)
{
    new 
length strlen(string);
    while ((
index length) && (string[index] <= ' '))
    {
        
index++;
    }
    new 
offset index;
    new 
result2[32]; // 7791
    
while ((index length) && (string[index] > ' ') && ((index offset) < (sizeof(result2) - 1)))
    {
        
result2[index offset] = string[index];
        
index++;
    }
    
result2[index offset] = EOS;
    return 
result2;




Re: local variable "result" shadows a variable at a preceding level - Fiore - 08.02.2013

I still get this error:

C:\Users\Fiore\Desktop\NIKOlikeAboss\gamemodes\woo tisidiot.pwn(7491) : error 025: function heading differs from prototype


Re : local variable "result" shadows a variable at a preceding level - yusei - 08.02.2013

new string2[256];


Re: local variable "result" shadows a variable at a preceding level - Fiore - 08.02.2013

pawn Код:
stock IsNumeric(const string2[]) // 7491
{
    new string2[256];
    if(strlen(string2) > 15) return 0;
    for (new i = 0, j = strlen(string2); i < j; i++)
    {
        if (string2[i] > '9' || string2[i] < '0') return 0;
    }
    return 1;
}
Like this doesnt work.


Re: local variable "result" shadows a variable at a preceding level - Fiore - 08.02.2013

any help please?