Picker wheel startIndex problem

Hi,

I have this pickerwheel:

         local smallIX = {}                     for i=1, 99 do                     smallIX[i] = i                     end         local columnData = {            { align = "center", width = 25, labels = smallIX, startIndex = operateBy }         }         pickerWheel = widget.newPickerWheel({                  id = "factorSelect",         font = "Helvetica-Bold",         left = centerX - 28,         top = centerY + 80,          overlayFrameHeight = 150,          overlayFrameWidth = 0,         columns = columnData     })

The object itself is declared as local at the top of my prefs scene, the only global is the value ‘operateBy’ which is set to 1 in the main file. The program enters the first scene where operateBy is used with its starting value of 1. Switching to the prefs scene there’s the picker wheel  which is supposed to allow selecting a new value for operateBy, which is also the value for the startIndex of the pickerwheel.

If I switch in between the two scenes without changing ‘operateBy’ with the pickerwheel no errors occur, but if I change the value and exit the prefs scene, where the pickerwheel is, and get back to it I get returned the general error ‘attemping to index ? field’ with a reference to the line where the pickerwheel is created… the prefs scene gets destroyed and then reloaded when called.

It’s as if the code is unable to associate the global variable to the startIndex value when modified.

Any idea on why this happens?

Thanks a lot.

 

Hi,

I just solved by feeding the startIndex paramater the global variable converted with ‘tonumber’.

Now, that variable has always been a number already, so I don’t really understand why this approach made the difference, but it actually did…

Hope someone find this useful.

Cheers!

Hi,

I just solved by feeding the startIndex paramater the global variable converted with ‘tonumber’.

Now, that variable has always been a number already, so I don’t really understand why this approach made the difference, but it actually did…

Hope someone find this useful.

Cheers!

I was hoping BIG-time that your solution of using tonumber() would solve my pWheel issue - but it didn’t.

My issue is that I have the SAME pWheel object called a 2nd time (in an overlay) in the same scene/session. In the first pass, the pWheel works as advertised - but on the 2nd try (after the 1st completed successfully), the startIndex element is literally removed from the array which builds the column for pWheel. without the startIndex element in the options table passed to pWheel object, the pWheel object crashes.

strange indeed.

Hi,

Sorry it is not working in your case. I would suggest inspecting around other things as the scope of your variable or checking its availability across scenes. Maybe it gets reset or messed with when changing/deleting the scene it is retrieved from?..

If something useful will come to mind I’ll post it right away.
Don’t give up :slight_smile:

I was hoping BIG-time that your solution of using tonumber() would solve my pWheel issue - but it didn’t.

My issue is that I have the SAME pWheel object called a 2nd time (in an overlay) in the same scene/session. In the first pass, the pWheel works as advertised - but on the 2nd try (after the 1st completed successfully), the startIndex element is literally removed from the array which builds the column for pWheel. without the startIndex element in the options table passed to pWheel object, the pWheel object crashes.

strange indeed.

Hi,

Sorry it is not working in your case. I would suggest inspecting around other things as the scope of your variable or checking its availability across scenes. Maybe it gets reset or messed with when changing/deleting the scene it is retrieved from?..

If something useful will come to mind I’ll post it right away.
Don’t give up :slight_smile: