pickerWheel crashes on 2nd time in via Overlay

I’m doing a biz app that includes several data entry screens for use on smartPhone.
 
On parent screen A, I call several “sub” screens, eg, 1, 2 and 3, via showOverlay() calls from A. I use pickerWheel objects on screens 1, 2 and 3 to facilitate data selection.
 
All has been working fine UNTIL I attempt the following: Screen A calls overlay-based screen 1. It captures the data and closes down via hideOverlay(), including the passing of the captured pickerWheel data. But if i RECALL screen 1, it always fails on the following line when going through setupDisplay(grp):

++++++++++++++++ this from setupDisplay()

options = {top =var.OL_pWheel_top ,

columns = pWheel_columns,

font=var.fontToUse,

fontSize=OL_pWheel_fontSize}

– create picker wheel

– FAILS ON THIS LINE ALWAYS

pWheel_BRF = widget.newPickerWheel (options)

++++++++++++++++

Note: I’m capturing params in the scene:create() section correctly. the options table is apparently coming back OK with a valid columns value on the recall.

The error again occurs when I re-access an Overlay()-based screen I have already called. the error is <<  ?:0: attempt to index field ‘?’ (a nil value)>> - and does NOT appear on the first access.

Do i need to destroy anything? Or do anything else special to handle the re-access?

thanks.

Can you post the complete error message (entire traceback stack) from the terminal console?

What version of Corona SDK are you using?  Are you on Windows or a Mac?

Rob

Copyright © 2009-2014  C o r o n a   L a b s   I n c .

Version: 3.0.0

Build: 2014.2511

 

Platform: iPhone / x86_64 / 10.10.0 / Intel Iris Pro OpenGL Engine / 2.1 INTEL-10.0.86 / 2014.2511

The file sandbox for this project is located at the following folder:

(/Users/Seth/Library/Application Support/Corona Simulator/4-52F797C83E5D6EDBBB3D72498F4D0FBF)

+++++++++++++++++++++++++++++++++++

 

Running on a Mac - fwiw, I just ported today all the code from a Windows environment to a MacBook Pro.

 

ERROR MSG

+++++++++++++++++++++++++++++++++++

Runtime error

?:0: attempt to index field ‘?’ (a nil value)

stack traceback:

?: in function <?:1535>

(tail call): ?

?: in function ‘?’

?: in function <?:428>

(tail call): ?

?: in function <?:122>

(tail call): ?

/Users/Seth/Library/Application Support/Outlaw/Sandbox/4/trackTime_new_OL_BRF.lua:143: in function ‘setupDisplay’

/Users/Seth/Library/Application Support/Outlaw/Sandbox/4/trackTime_new_OL_BRF.lua:194: in function </Users/Seth/Library/Application Support/Outlaw/Sandbox/4/trackTime_new_OL_BRF.lua:185>

?: in function ‘dispatchEvent’

?: in function ‘showOverlay’

/Users/Seth/Library/Application Support/Outlaw/Sandbox/4/trackTime_new.lua:160: in function ‘_onPress’

?: in function ‘?’

?: in function <?:449>

?: in function <?:221>

+++++++++++++++++++++++++++++++++++++++

 

fwiw2 - the CS shows what appears to be the column values being generated - and in an operating spinner – for the pickerWheel object - but the "object’ is basic, white, scrollable of the expected values and found in the upper left corner of CS, occupying about half the screenWidth.

 

I have two other OLs which depend on pickerWheel objects in the same manner. I will transfer the code to those scenes and see what results. I also have OLs but do not employ pickerWheels. All of these screens pass params back and forth.

 

If you’d like screenshots/specific code, please ask.

 

Thanks for taking a look, Rob - I’m designing specifically for phone biz apps which fully minimize typing so these data-picking tools are critical to managing data on these types of apps. I do believe Corona’s a well-designed product - nice work to your group.

 

Happy Spring time - snow remains in the Catskills.

What is this line of code?   trackTime_new_OL_BRF.lua:143

Rob

LINE 143

pWheel_BRF = widget.newPickerWheel (options)

 

OTHER RELEVANT CODE

local pWheel_columns = getBRF()

– options

options = {top =var.OL_pWheel_top ,

columns = pWheel_columns,

font=var.fontToUse,

fontSize=OL_pWheel_fontSize}

– create

[LINE 143]  pWheel_BRF = widget.newPickerWheel (options)

grp:insert(pWheel_BRF)

I would suggest printing out the values of var.OL_pWheel_top, pWheel_columns, var.fontToUse, OL_pWheel_fontSize and see if one of them is nil when you create the new picker wheel.  Then you can try to figure out why those values are not surviving the process.  it’s possible you might be destroying a scene that had them defined in it and because of the way Lua loads modules, it might not be re-creating the way you think.

Rob

on the 2nd pass, the startIndex value is completely missing from the options table of values passed to the pickerWheel; on the first pass, the startIndex value is provided. the problems begin to occur in the 2nd pass where startIndex is defined by table.indexOf(listDataBRF,setBRF)

In both passes array = listDataBRF is correctly formatted with expected and valid values and the value = setBRF is correctly defined; yet in the 2nd pass the startIndex calc goes to nil.

something is going awry in table.indexOf() calc.

Tnanks for any further insight you might provide. Rob.

Here are relevant print() outputs:

PASS 1

– this is table/array of the actual values which will create the sole column to this pickerWheel object

table: 0x7fab009683b0 {

[1] => 0

[2] => 0.1

[3] => 0.2

[4] => 0.3

[5] => 0.4

[6] => 0.5

[7] => 0.6

[8] => 0.7

[9] => 0.8

[10] => 0.9

[11] => 1

[12] => 1.1

[13] => 1.2

[14] => 1.3

[15] => 1.4

[16] => 1.5

[17] => 1.6

[18] => 1.7

[19] => 1.8

[20] => 1.9

[21] => 2

[22] => 2.1

[23] => 2.2

[24] => 2.3

[25] => 2.4

[26] => 2.5

[27] => 2.6

[28] => 2.7

[29] => 2.8

[30] => 2.9

}

 

PASS 1 - just after above array generated

the following print() output shows the indexOf value is 11 based on a default value of 1 (ie, setBRF = 1)

 

print(“IndexOf - setBRF”,table.indexOf(listDataBRF,setBRF),setBRF) -->> IndexOf - setBRF 11 1

 

PASS 1 - the options table passed to the pickerWheel object in setupDisplay

notice that startIndex = 11

 

table: 0x7fab00861850 {

[top] => 160

[font] => “Helvetica”

[columns] => table: 0x7fab00861850 {

[1] => table: 0x7fab00840d70 {

[align] => “center”

[startIndex] => 11

[labels] => table: 0x7fab00861810 {

[1] => 0

[2] => 0.1

[3] => 0.2

[4] => 0.3

[5] => 0.4

[6] => 0.5

[7] => 0.6

[8] => 0.7

[9] => 0.8

[10] => 0.9

[11] => 1

[12] => 1.1

 

[13] => 1.2

[14] => 1.3

[15] => 1.4

[16] => 1.5

[17] => 1.6

[18] => 1.7

[19] => 1.8

[20] => 1.9

[21] => 2

[22] => 2.1

[23] => 2.2

[24] => 2.3

[25] => 2.4

[26] => 2.5

[27] => 2.6

[28] => 2.7

[29] => 2.8

[30] => 2.9}}}}

 

PASS 2

– this is table/array of the actual values which will create the sole column to this pickerWheel object

– it is identical to initial pass

table: 0x7faafa55c300 {

[1] => 0

[2] => 0.1

[3] => 0.2

[4] => 0.3

[5] => 0.4

[6] => 0.5

[7] => 0.6

[8] => 0.7

[9] => 0.8

[10] => 0.9

[11] => 1

[12] => 1.1

[13] => 1.2

[14] => 1.3

[15] => 1.4

[16] => 1.5

[17] => 1.6

[18] => 1.7

[19] => 1.8

[20] => 1.9

[21] => 2

[22] => 2.1

[23] => 2.2

[24] => 2.3

[25] => 2.4

[26] => 2.5

[27] => 2.6

[28] => 2.7

[29] => 2.8

[30] => 2.9}

 

PASS 2 - just after above array generated

FYI: In Pass 1, the BRF was set to 1.5 and shows up correctly here

the following print() output shows the indexOf value is NIL based on a default value of 1.5 (ie, setBRF = 1.5)

print(“IndexOf - setBRF”,table.indexOf(listDataBRF,setBRF),setBRF) -->> IndexOf - setBRFnil 1.5

 

PASS 2 - the options table passed to the pickerWheel object in setupDisplay

notice that startIndex is now MISSING – even though array = listDataBRF is correctly formatted and setBRF = 1.5, which is a valid member of listDataBRF

 

table: 0x7faafa4ccf80 {

[top] => 160

[font] => “Helvetica”

[columns] => table: 0x7faafa4ccf80 {

[1] => table: 0x7fab0085d310 {

[align] => “center”

[labels] => table: 0x7fab0086fc10 {

[1] => 0

[2] => 0.1

[3] => 0.2

[4] => 0.3

[5] => 0.4

[6] => 0.5

[7] => 0.6

[8] => 0.7

[9] => 0.8

[10] => 0.9

[11] => 1

[12] => 1.1

[13] => 1.2

 

[14] => 1.3

[15] => 1.4

[16] => 1.5

[17] => 1.6

[18] => 1.7

[19] => 1.8

[20] => 1.9

[21] => 2

[22] => 2.1

[23] => 2.2

[24] => 2.3

[25] => 2.4

[26] => 2.5

[27] => 2.6

[28] => 2.7

[29] => 2.8

[30] => 2.9}}}}

this issue is resolved using tonumber() and tostring() conversions. A small quirk involved specific decimals > 0.0 and < 1.0

AKAK at http://forums.coronalabs.com/topic/53761-picker-wheel-startindex-problem/?hl=startindex provided a hint when his issue was solved using tonumber().

these are my observations in getting this resolved, ie, determining a valid startIndex value for the pickerWheel.

  1. listDataBRF is an array with VALUES of 0,1,2,3,4 - and decimal VALUES in between eg, 0.25, 0.50, 1.00, 1.25

  2. setBRF is the VALUE to be found in the listDataBRF - default = 1.0

  3. table.indexOf() was retuning nil even if “valid” values (to the eye) were presented

  4. applying tonumber() in the FIRST line, below, resolved all matches for INTEGERS and any decimal 1.00 or higher

  5. applying the tostring() functionsin the PAIRS loop resolved decimal values > 0.0 and < 1.0

++++++++++++++++

setStartIndex = tonumber(table.indexOf(listDataBRF,setBRF))

if setStartIndex == nil then

–serious issue – assign by loop

for key, value in pairs( listDataBRF ) do

  if tostring(value) == tostring(setBRF) then

    setStartIndex = tonumber(key)

    end

end

end

if setStartIndex == nil then

setStartIndex = table.indexOf(listDataBRF,BRFDefault)

end

++++++++++++++++

Can you post the complete error message (entire traceback stack) from the terminal console?

What version of Corona SDK are you using?  Are you on Windows or a Mac?

Rob

Copyright © 2009-2014  C o r o n a   L a b s   I n c .

Version: 3.0.0

Build: 2014.2511

 

Platform: iPhone / x86_64 / 10.10.0 / Intel Iris Pro OpenGL Engine / 2.1 INTEL-10.0.86 / 2014.2511

The file sandbox for this project is located at the following folder:

(/Users/Seth/Library/Application Support/Corona Simulator/4-52F797C83E5D6EDBBB3D72498F4D0FBF)

+++++++++++++++++++++++++++++++++++

 

Running on a Mac - fwiw, I just ported today all the code from a Windows environment to a MacBook Pro.

 

ERROR MSG

+++++++++++++++++++++++++++++++++++

Runtime error

?:0: attempt to index field ‘?’ (a nil value)

stack traceback:

?: in function <?:1535>

(tail call): ?

?: in function ‘?’

?: in function <?:428>

(tail call): ?

?: in function <?:122>

(tail call): ?

/Users/Seth/Library/Application Support/Outlaw/Sandbox/4/trackTime_new_OL_BRF.lua:143: in function ‘setupDisplay’

/Users/Seth/Library/Application Support/Outlaw/Sandbox/4/trackTime_new_OL_BRF.lua:194: in function </Users/Seth/Library/Application Support/Outlaw/Sandbox/4/trackTime_new_OL_BRF.lua:185>

?: in function ‘dispatchEvent’

?: in function ‘showOverlay’

/Users/Seth/Library/Application Support/Outlaw/Sandbox/4/trackTime_new.lua:160: in function ‘_onPress’

?: in function ‘?’

?: in function <?:449>

?: in function <?:221>

+++++++++++++++++++++++++++++++++++++++

 

fwiw2 - the CS shows what appears to be the column values being generated - and in an operating spinner – for the pickerWheel object - but the "object’ is basic, white, scrollable of the expected values and found in the upper left corner of CS, occupying about half the screenWidth.

 

I have two other OLs which depend on pickerWheel objects in the same manner. I will transfer the code to those scenes and see what results. I also have OLs but do not employ pickerWheels. All of these screens pass params back and forth.

 

If you’d like screenshots/specific code, please ask.

 

Thanks for taking a look, Rob - I’m designing specifically for phone biz apps which fully minimize typing so these data-picking tools are critical to managing data on these types of apps. I do believe Corona’s a well-designed product - nice work to your group.

 

Happy Spring time - snow remains in the Catskills.

What is this line of code?   trackTime_new_OL_BRF.lua:143

Rob

LINE 143

pWheel_BRF = widget.newPickerWheel (options)

 

OTHER RELEVANT CODE

local pWheel_columns = getBRF()

– options

options = {top =var.OL_pWheel_top ,

columns = pWheel_columns,

font=var.fontToUse,

fontSize=OL_pWheel_fontSize}

– create

[LINE 143]  pWheel_BRF = widget.newPickerWheel (options)

grp:insert(pWheel_BRF)

I would suggest printing out the values of var.OL_pWheel_top, pWheel_columns, var.fontToUse, OL_pWheel_fontSize and see if one of them is nil when you create the new picker wheel.  Then you can try to figure out why those values are not surviving the process.  it’s possible you might be destroying a scene that had them defined in it and because of the way Lua loads modules, it might not be re-creating the way you think.

Rob

on the 2nd pass, the startIndex value is completely missing from the options table of values passed to the pickerWheel; on the first pass, the startIndex value is provided. the problems begin to occur in the 2nd pass where startIndex is defined by table.indexOf(listDataBRF,setBRF)

In both passes array = listDataBRF is correctly formatted with expected and valid values and the value = setBRF is correctly defined; yet in the 2nd pass the startIndex calc goes to nil.

something is going awry in table.indexOf() calc.

Tnanks for any further insight you might provide. Rob.

Here are relevant print() outputs:

PASS 1

– this is table/array of the actual values which will create the sole column to this pickerWheel object

table: 0x7fab009683b0 {

[1] => 0

[2] => 0.1

[3] => 0.2

[4] => 0.3

[5] => 0.4

[6] => 0.5

[7] => 0.6

[8] => 0.7

[9] => 0.8

[10] => 0.9

[11] => 1

[12] => 1.1

[13] => 1.2

[14] => 1.3

[15] => 1.4

[16] => 1.5

[17] => 1.6

[18] => 1.7

[19] => 1.8

[20] => 1.9

[21] => 2

[22] => 2.1

[23] => 2.2

[24] => 2.3

[25] => 2.4

[26] => 2.5

[27] => 2.6

[28] => 2.7

[29] => 2.8

[30] => 2.9

}

 

PASS 1 - just after above array generated

the following print() output shows the indexOf value is 11 based on a default value of 1 (ie, setBRF = 1)

 

print(“IndexOf - setBRF”,table.indexOf(listDataBRF,setBRF),setBRF) -->> IndexOf - setBRF 11 1

 

PASS 1 - the options table passed to the pickerWheel object in setupDisplay

notice that startIndex = 11

 

table: 0x7fab00861850 {

[top] => 160

[font] => “Helvetica”

[columns] => table: 0x7fab00861850 {

[1] => table: 0x7fab00840d70 {

[align] => “center”

[startIndex] => 11

[labels] => table: 0x7fab00861810 {

[1] => 0

[2] => 0.1

[3] => 0.2

[4] => 0.3

[5] => 0.4

[6] => 0.5

[7] => 0.6

[8] => 0.7

[9] => 0.8

[10] => 0.9

[11] => 1

[12] => 1.1

 

[13] => 1.2

[14] => 1.3

[15] => 1.4

[16] => 1.5

[17] => 1.6

[18] => 1.7

[19] => 1.8

[20] => 1.9

[21] => 2

[22] => 2.1

[23] => 2.2

[24] => 2.3

[25] => 2.4

[26] => 2.5

[27] => 2.6

[28] => 2.7

[29] => 2.8

[30] => 2.9}}}}

 

PASS 2

– this is table/array of the actual values which will create the sole column to this pickerWheel object

– it is identical to initial pass

table: 0x7faafa55c300 {

[1] => 0

[2] => 0.1

[3] => 0.2

[4] => 0.3

[5] => 0.4

[6] => 0.5

[7] => 0.6

[8] => 0.7

[9] => 0.8

[10] => 0.9

[11] => 1

[12] => 1.1

[13] => 1.2

[14] => 1.3

[15] => 1.4

[16] => 1.5

[17] => 1.6

[18] => 1.7

[19] => 1.8

[20] => 1.9

[21] => 2

[22] => 2.1

[23] => 2.2

[24] => 2.3

[25] => 2.4

[26] => 2.5

[27] => 2.6

[28] => 2.7

[29] => 2.8

[30] => 2.9}

 

PASS 2 - just after above array generated

FYI: In Pass 1, the BRF was set to 1.5 and shows up correctly here

the following print() output shows the indexOf value is NIL based on a default value of 1.5 (ie, setBRF = 1.5)

print(“IndexOf - setBRF”,table.indexOf(listDataBRF,setBRF),setBRF) -->> IndexOf - setBRFnil 1.5

 

PASS 2 - the options table passed to the pickerWheel object in setupDisplay

notice that startIndex is now MISSING – even though array = listDataBRF is correctly formatted and setBRF = 1.5, which is a valid member of listDataBRF

 

table: 0x7faafa4ccf80 {

[top] => 160

[font] => “Helvetica”

[columns] => table: 0x7faafa4ccf80 {

[1] => table: 0x7fab0085d310 {

[align] => “center”

[labels] => table: 0x7fab0086fc10 {

[1] => 0

[2] => 0.1

[3] => 0.2

[4] => 0.3

[5] => 0.4

[6] => 0.5

[7] => 0.6

[8] => 0.7

[9] => 0.8

[10] => 0.9

[11] => 1

[12] => 1.1

[13] => 1.2

 

[14] => 1.3

[15] => 1.4

[16] => 1.5

[17] => 1.6

[18] => 1.7

[19] => 1.8

[20] => 1.9

[21] => 2

[22] => 2.1

[23] => 2.2

[24] => 2.3

[25] => 2.4

[26] => 2.5

[27] => 2.6

[28] => 2.7

[29] => 2.8

[30] => 2.9}}}}

this issue is resolved using tonumber() and tostring() conversions. A small quirk involved specific decimals > 0.0 and < 1.0

AKAK at http://forums.coronalabs.com/topic/53761-picker-wheel-startindex-problem/?hl=startindex provided a hint when his issue was solved using tonumber().

these are my observations in getting this resolved, ie, determining a valid startIndex value for the pickerWheel.

  1. listDataBRF is an array with VALUES of 0,1,2,3,4 - and decimal VALUES in between eg, 0.25, 0.50, 1.00, 1.25

  2. setBRF is the VALUE to be found in the listDataBRF - default = 1.0

  3. table.indexOf() was retuning nil even if “valid” values (to the eye) were presented

  4. applying tonumber() in the FIRST line, below, resolved all matches for INTEGERS and any decimal 1.00 or higher

  5. applying the tostring() functionsin the PAIRS loop resolved decimal values > 0.0 and < 1.0

++++++++++++++++

setStartIndex = tonumber(table.indexOf(listDataBRF,setBRF))

if setStartIndex == nil then

–serious issue – assign by loop

for key, value in pairs( listDataBRF ) do

  if tostring(value) == tostring(setBRF) then

    setStartIndex = tonumber(key)

    end

end

end

if setStartIndex == nil then

setStartIndex = table.indexOf(listDataBRF,BRFDefault)

end

++++++++++++++++