Raised This Month: $ Target: $400
 0% 

[ index out of bounds ]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Xablau
Member
Join Date: Dec 2014
Old 01-08-2015 , 20:29   [ index out of bounds ]
Reply With Quote #1

I have problem

Error: index out of bounds on line:
PHP Code:
parse(lines[i], line_variableSIZEline_valueSIZEline_value2SIZE
See my code:

PHP Code:
public client_putinserver(pid)
{
    new 
errorsendbuffer[512]

    
g_Socket socket_open("127.0.0.1"80SOCKET_TCPerror)
    
    
format(sendbuffer511"GET /web.php HTTP/1.1^nHost: 127.0.0.1^n^n")
        
    
socket_send(g_Socketsendbuffer511)
    
    const 
SIZE 63
    
new line_variable[SIZE 1], line_value[SIZE 1], line_value2[SIZE 1]
    
    if (
socket_change(g_Socket))
    {
        new 
lines[30][100], count 0
        socket_recv
(g_Socketg_Data1024)
        
count ExplodeString(lines50119g_Data13)
        for(new 
i=0;i<count;i++)
        {
            
parse(lines[i], line_variableSIZEline_valueSIZEline_value2SIZE)

            
// 100 lines in web.php ...
            // Continue...
        
}   
    }
    
socket_close(g_Socket)
    return 
PLUGIN_CONTINUE;
}
stock ExplodeStringp_szOutput[][], p_nMaxp_nSizep_szInput[], p_szDelimiter ) { // Function by xeroblood
    
new nIdx 0strlen(p_szInput)
    new 
nLen = (copycp_szOutput[nIdx], p_nSizep_szInputp_szDelimiter ))
    while( (
nLen l) && (++nIdx p_nMax) )
        
nLen += (copycp_szOutput[nIdx], p_nSizep_szInput[nLen], p_szDelimiter ))
    return 
nIdx

lines[30][100] to lines[100][100] not work.

In web.php have 100 lines:
"Value 1" "Value 2" "Value 3"

How to Fix problem?

Last edited by Xablau; 01-08-2015 at 20:33.
Xablau is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-08-2015 , 20:44   Re: [ index out of bounds ]
Reply With Quote #2

You need to learn to debug these things on your own if you are going to keep asking about trivial problems.

When you are working with strings and need to know the maximum string length (arguments 3, 5, and 7 of the parse command), you should be charsmax(szStringVariable).
__________________
fysiks is offline
Xablau
Member
Join Date: Dec 2014
Old 01-08-2015 , 20:59   Re: [ index out of bounds ]
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
You need to learn to debug these things on your own if you are going to keep asking about trivial problems.

When you are working with strings and need to know the maximum string length (arguments 3, 5, and 7 of the parse command), you should be charsmax(szStringVariable).
The index out of bounds refers to the limit of entries in lines being greater than 31

lines[30][100] to lines[100][100] not work, with error: stack error

and...

PHP Code:
parse(lines[i], line_variablecharsmax(line_variable), line_valuecharsmax(line_value), line_value2charsmax(line_value2)) 
not work...

How to fix?

Last edited by Xablau; 01-08-2015 at 21:00.
Xablau is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-08-2015 , 22:10   Re: [ index out of bounds ]
Reply With Quote #4

Like I said, you need to learn to debug. What happens when you change it to 200 string? What is the value of 'count'?

P.S. stop putting brackets around your whole topic title.
__________________

Last edited by fysiks; 01-08-2015 at 22:10.
fysiks is offline
Xablau
Member
Join Date: Dec 2014
Old 01-09-2015 , 04:40   Re: [ index out of bounds ]
Reply With Quote #5

count = ExplodeString(lines, 50, 119, g_Data, 13) //100 (Have 100 lines on web.php)

I noticed that exceed 30 lines, gives the error: index out of bounds

If change lines[30][100] to lines[100][100], give error:
stack error on lines[100][100]
Xablau is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-09-2015 , 18:33   Re: [ index out of bounds ]
Reply With Quote #6

If you are going to ignore questions/advice then I'm just going to stop posting.
__________________
fysiks is offline
Xablau
Member
Join Date: Dec 2014
Old 01-09-2015 , 18:51   Re: [ index out of bounds ]
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
If you are going to ignore questions/advice then I'm just going to stop posting.
I'm not ignoring. Excuse my bad English. =/

I tried your suggestions, but none worked yet.
Xablau is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-09-2015 , 18:55   Re: [ index out of bounds ]
Reply With Quote #8

Attach your web.php and your whole .sma files.
__________________
fysiks is offline
Xablau
Member
Join Date: Dec 2014
Old 01-09-2015 , 19:31   Re: [ index out of bounds ]
Reply With Quote #9

Quote:
Originally Posted by fysiks View Post
Attach your web.php and your whole .sma files.
Attach
Attached Files
File Type: sma Get Plugin or Get Source (fysiks.sma - 551 views - 2.5 KB)
File Type: txt web.php.txt (1.6 KB, 101 views)
Xablau is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:31.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode