Select list item error: “Attempt to get item number 0” (but logic seems correct)

Hi everyone,

I’m building a paging UI in MIT App Inventor with:

  • 8 products in a list
  • 5 buttons showing products
  • FastForward / FastBackward buttons

Logic: circular paging using modulo/remainder.

Problem:
I keep getting this runtime error:

Select list item: Attempt to get item number 0. The minimum valid item number is 1.

Even though:

  • StartIndex is initialized to 1
  • CurrentIndex is calculated using modulo
  • App mostly works visually

Refresh logic (simplified):

CurrentIndex = ((StartIndex + number − 2) mod length Products) + 1

Buttons set using ButtonList[number].

Has anyone faced this issue where modulo logic is correct but index 0 error still appears?
What could cause CurrentIndex to briefly become 0?

Thanks in advance :blush: attached is the screen shoot of relevent blocks and its aia


flung (1).aia (1.0 MB)

put the set button text block inside the if statement, it is probably running before Currentindex is set to length of list.

Since the forward and backward buttons are not declared in the button list, the error is inevitable.