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.