Joined: 13 Jun 2022 Posts: 12 Location: South America
Posted: Fri Sep 22, 2023 10:01 pm Post subject: ignore "out of bounds error"
I ended up in a very specific situation, I need to choose index 46 of the AOB if it exists, but if I do an if and it doesn't exist, the "out of bounds" error will obviously occur, so... what do I do? Is there any way to ignore this error and jump to the else block?
You can check how many elements there are with the "Count" property
Code:
local results = AOBScan('...')
local whatever
-- AOBScan returns nil on failure
if results then
if results.Count >= 47 then
whatever = results[36]
elseif results.Count >= 15 then
whatever = results[14]
end
-- don't forget to destroy the stringlist (if it exists)
results.destroy()
end
_________________
I don't know where I'm going, but I'll figure it out when I get there.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum