Accessing List Index from Script?

How can I access the index of an item in a list view? I have a button in my list row, and I'm simply trying to log the index of this button to the console. Everywhere I've read says to use the "magic i" variable but in my run script action it says "i" is undefined.

This community post may be helpful --