Jump to content
UBot Underground

[SOLVED] Exceeded The Range Of The List


Recommended Posts

This is really causing me confusion.

 

I run this code in a stand alone environment and it does fine - No errors, no issues.

 

post-5035-0-86259700-1358829595_thumb.jpg

 

 

However, if I put this code (which is a self contained unit it seems) in with the code in a larger bot, I get the error of exceeded the range of the list on next list item.

 

Can anyone explain to me why this happens?

Link to post
Share on other sites

Probably you need to CLEAR LIST before using it.

 

I am assuming you are testing it and see it works, using the DEBUGGER and clearing all variables between sessions, but when ported into the actual code, if the code repeats itself somehow (inside a loop or something) your list indexes are overflown...  just a guess.

Link to post
Share on other sites

I just gave it a try Vboss. - Same issue. The "set>keywordvar>next list item   -- is still throwing the error... I'm at a complete loss on this -- any other ideas? I'll happily try it.

Link to post
Share on other sites

Because you are using $next list item, you might exceed the index, as the function not only returns the item, but also moves the pointer on the list at the same time - so when you get to the last item in the list, the code tries in fact to move forward but there is no place to move.

 

I rarely use $next list item, because of that... hard to keep the score:  "Where am I now?"  kinda...

 

I use clear cycling instead, where the list item is returned via $list item function and the index is cycled
between (MAX list length - 1) and 0, decrementing on each loop, using LOOP WHILE.   Hope this makes sense?

 

set(#var_CYC_Keyword_CRT, $list total(%lst_Keywords), "Global")

loop while($comparison(#var_CYC_Keyword_CRT, ">", 0)) {
    decrement(#var_CYC_Keyword_CRT)

    comment("YOUR CODE HERE")
.....................................
    comment("YOUR CODE HERE")
}
  • Like 2
Link to post
Share on other sites

vBoss - your example is a little above my pay grade... However! Thanks for sharing it - I can now play around with your method and learn it.

 

As for the issue I was having. It was a complete gooftard moment. I simply needed to reset the list position immediately before execution. (pffft. Spent hours on something so simple)

 

Thanks for all of your help around here man - I really appreciate it.

Link to post
Share on other sites

No problems, mate... glad you solved your issue in any way you could do it.

 

On the other hand, my solution up there is - hands down - THE simplest, cleanest and most beautiful of all loop-ing methods; 
but not because it's mine...

...simply because it really condenses code quite a lot, while still providing for the ability to employ other means to split command flow
by forcing the cycling index down to 0 inside a branch of an IF, in order to exit the loop before it would normally end,
IF/WHEN a certain condition is met (usually you found your item you were seeking...)
thus also speeding the execution of the bots where it is used.

 

So basically:

  • easier to write,
  • lesser amount of used variables,
  • easier to debug,
  • precise handling of index/position,
  • smaller size of bot code,
  • faster execution.

It has it all...

  • Like 1
Link to post
Share on other sites
  • 2 weeks later...

I had this problem too and solved it easily but it is a bug that needs to be fixed. For some reason ubot couldn't handle a "list from text" function unless it had 3 or more values. 

 

I had 2 "items" seperated with a "," for example: 

 

a,b,

c,d,

e,f,

etc...

 

And I was getting the same error, to fix it all I did was add a 3rd useless item like this:

 

whatever,a,b,

whatever,c,d,

whatever,e,f,

etc...

 

Hope the dev team can fix this little bug. 

Edited by ayzo
Link to post
Share on other sites

There is no bug - that command works perfectly.

 

It must be an error in the logic flow of your code.

 

If you share the code here, we might be able to help you spot it.

 

My guess is you're exceeding the list index, because you somehow use an indexing based on starting with first element numbering with 1, when in fact it is 0, hence the $list total value refers to an nonexistent last element, that is actually one step behind in reality. 

 

It looks like adding an extra element that you don't need in the list, you kinda 'moved' the boundary one step ahead this way, and your code seems to work with it, although there was no need to add anything extra, it would have been simpler to just decrement the max list number.


But of course, might be other things as well - w/o the code is really hard to tell.

 

Cheers!

  • Like 1
Link to post
Share on other sites

Thanks guys - I thrive to better myself in everything I do;  I'm a perfectionist, what can I say...

 

Strangely though (one would think the opposite should apply) my wife said it was one of my flaws... LOL

 

Phew... women...  they marry us for what we were... but then they get bored at what we became, moulded by their hands:

"Where is the man I married that long ago?"

 

Can you believe that?  LOL

 

^^^ just kiddin' - I'm no misogynistic type of guy here...

Link to post
Share on other sites
  • 7 months later...

 

Because you are using $next list item, you might exceed the index, as the function not only returns the item, but also moves the pointer on the list at the same time - so when you get to the last item in the list, the code tries in fact to move forward but there is no place to move.

 

I rarely use $next list item, because of that... hard to keep the score:  "Where am I now?"  kinda...

 

I use clear cycling instead, where the list item is returned via $list item function and the index is cycled

between (MAX list length - 1) and 0, decrementing on each loop, using LOOP WHILE.   Hope this makes sense?

set(#var_CYC_Keyword_CRT, $list total(%lst_Keywords), "Global")

loop while($comparison(#var_CYC_Keyword_CRT, ">", 0)) {
    decrement(#var_CYC_Keyword_CRT)

    comment("YOUR CODE HERE")
.....................................
    comment("YOUR CODE HERE")
}

I'm at a complete loss with this.  It only returns a count of where the loop is at, but not the item on the list.  

Link to post
Share on other sites
  • 3 years later...

i know this topic is closed but i was struggling with this and tried the methods on here with no luck so i played around and figured out why that error always happens. Its very simple.

 

Set list position to 0 then run your next list item, not sure why it took me a freaking month to figure that crap out smh! lol but i hope this helps someone else. easy said, please refer to good ol wiki!, http://wiki.ubotstud...$next_list_item

Edited by djgbshows
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...