1.2.4 Survey Says Runtime Error

Hello MIT Community,

One of my students has situated his code based off the PLTW curriculum for 1.2.4 Survey Says. My whole class and I have analyzed his code from top to bottom and can't seem to get rid of this Runtime Error that's attached. I've uploaded a screenshot of their code as well to show what we have been looking at for a few days. Any help would be appreciated.

The index in list block returns 0, if the "thing" was not found in the list ...
Just check for 0 before using the replace list item block

Taifun

Is that in reference to the list block in Screen1 or AddFlavorButton?

ccd35e70e83d310b7b1e5727a822075b77aae76c_2_690x486

There is an unspoken Assertion in effect for your code to work, that FlavorPicker.Selection should contain a flavor.

But the FlavorPicker .AfterPicking event violates that convention, by adding 'You picked' to the Selection, thus thwarting the index determination in global flavorList.

Find an alternative way to display the selection, for example by using a List Picker and setting its .Text to the embellished Selection value.

P.S. I searched for some imagery to show how bad an idea it is to allow data to flow backwards in a system, just as how bad it is for a plumbing system to allow water to flow backwards.

This is as close as I could come:
Sip-of-Conflict-girl-960x916

1 Like

The FlavorPicker .AfterPicking was the culprit! Thank you all so much for the assistance!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.