Using choice selectedIndex properties

I’m having difficulty with leveraging choiceInput selectedIndex property and using them as an index into a numberList:

  <choiceInput name="R3selected" inline preserveLastChoice="false" bindValueTo="$R3display">
    <choice>$PotentiometerStrings[1]</choice><!-- 1 -->
    <choice>$PotentiometerStrings[2]</choice> <!-- 2 -->
  </choiceInput>

and later in the code:
$PotentiometerValues[$R3selected.selectedIndex]

where $PotentiometerValues is just a numberList

On ‘Update’, the interpretter gives me the following error:
“Definition of state variable value of 2990 requested essential or default value of value, but hasEssential is not set.”

Running version v0.7.26

Here is the code: Doenet

I’m not clear what I’m doing wrong. The selected index should just behave like a number; using it to reference inside a number list seems normal.

In a similar vein, it gives weird errors:
$R1selected.selectedIndex-1
$R2selected.selectedIndex-1
$R3selected.selectedIndex

<integer name="R1value">$ResistorValuesWOZero[ $R1SelectionIndex ]</integer>
<integer name="R2value">$ResistorValuesWOZero[ $R2selectionIndex ] </integer>
<integer name="R3value">$PotentiometerValues[ $R3selectionIndex ]</integer>

it will give me “No referent found” but not on all lines, but twice on the R2SelectionIndex and R3SelectionIndex lines, and on each of the Rxvalue lines.

Again, it is not clear what is going wrong. These feel like pretty normal index and index use declarations.

That is definitely a bug in Doenet. Created a bug report that diagnoses it.

The offending line is

<integer name="R3value">$PotentiometerValues[$R3selected.selectedIndex]</integer>

A workaround until we fix it is to change it to ...selectedIndex+0]

Yes, we also currently have a number of spurious “No referent found” warnings. You can ignore them until we stamp all of those out.

I released a new dev version with this fix. (You’d have to change to version 0.7dev and possibly clear your cache to test it out.) I hope to release a new official version soon with the accumulated fixes.