Jump to content
  • 0

ArrayIndexOutOfBoundsException problem


Question

Posted

I have an Array that I know has 57 values as i printed the array and it its value count prior to running the following

for i,v in ipairs(newpids) do
    check = string.find(ids, v)
    if check ~= nil then
        --do stuff
    else
        --do other stuff

    end

end

And I get the following

ArrayIndexOutOfBoundsException: length=12: index=12

which is not making any sense since I know the array is 57 values long or I may be misunderstanding something here

 

12 answers to this question

Recommended Posts

  • 0
Posted (edited)

edit: thought i had it but the second run error again

Edited by BadCase
  • 0
Posted

Ok now im getting ArrayIndexOutOfBoundsException errors on functions that do not even involve arrays does it throw these if there are memory issues or something?

  • 0
Posted

thanks for the reply, this is a private script so I can't post it but if I encounter it in another one I will revisit this thread

Need full text of error and full text of script for reproduce it.
  • 0
Posted
7 hours ago, Enyby said:

Full text of error too private?

Is this it or is therer more in a file somewhere?

 

Script ended:
Perhaps this script needs the latest version of GameGuardian. Try to update to the latest version.

Script error: org.luaj.vm2.LuaError: @/storage/emulated/0/Download/SaveEditorPACYBITSfutBadCase1.0.0.lua:86
`    check = string.find(ids, v)`
vm error: java.lang.ArrayIndexOutOfBoundsException: length=12; index=12
level = 1, pc = 160
stack traceback:
    /storage/emulated/0/Download/SaveEditorPACYBITSfutBadCase1.0.0.lua:86 in function 'loadxml'
    /storage/emulated/0/Download/SaveEditorPACYBITSfutBadCase1.0.0.lua:5 in function 'home'
    /storage/emulated/0/Download/SaveEditorPACYBITSfutBadCase1.0.0.lua:738 in main chunk
    [Java]: in ?
    at org.luaj.vm2.LuaClosure.execute(LuaClosure.java:583)
    at org.luaj.vm2.LuaClosure.call(LuaClosure.java:145)
    at org.luaj.vm2.LuaClosure.execute(LuaClosure.java:427)
    at org.luaj.vm2.LuaClosure.call(LuaClosure.java:145)
    at org.luaj.vm2.LuaClosure.execute(LuaClosure.java:427)
    at org.luaj.vm2.LuaClosure.call(LuaClosure.java:145)
    at android.ext.Script.runScript(Script.java:5096)
    at android.ext.Script$ScriptThread.run(Script.java:4896)
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=12; index=12
    at org.luaj.vm2.LuaString.luaByte(LuaString.java:576)
    at org.luaj.vm2.lib.StringLib$MatchState.classend(StringLib.java:1016)
    at org.luaj.vm2.lib.StringLib$MatchState.match(StringLib.java:1132)
    at org.luaj.vm2.lib.StringLib.str_find_aux(StringLib.java:816)
    at org.luaj.vm2.lib.StringLib$find.invoke(StringLib.java:225)
    at org.luaj.vm2.lib.VarArgFunction.call(VarArgFunction.java:62)
    at org.luaj.vm2.LuaClosure.execute(LuaClosure.java:433)
    ... 7 more


Script wrote 38.63KB in 1 files

  • 0
Posted

Which patterns did you use, if it's not private info? Pattern is second argument of the call to string.find function, in your case it's value of the variable "v".

  • 0
Posted

v is the current value from the array that the for is being done on, the array contains 57 values all values consist of the letters "id" followed by a series of numbers

  • 0
  • Administrators
Posted

Mistake in pattern. Not closed a frontier pattern. Something like that:

ids = '01234567890'
v = '01234567%f[%'
check = string.find(ids, v)
print(check, ids, v)

 

  • 0
Posted

I am little late, because the answer is already given, but have one thing to add.
If you need to match '[' character in the string, insert escape character ('%') before it, example: "abc123%[59959".
Additional info about patterns in Lua can be found here: https://www.lua.org/pil/20.2.html

  • 0
Posted (edited)
2 hours ago, Enyby said:

Mistake in pattern. Not closed a frontier pattern. Something like that:


ids = '01234567890'
v = '01234567%f[%'
check = string.find(ids, v)
print(check, ids, v)

 

yup i bet that is it just looked at the array again and a [ made it through my file parsing and is at the beginning of the first array value, Thanks again for the help

Edited by BadCase

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.