If this program is run as is it will show the erroneous execution. Remove the rem at line 87 and the program will return before assigning the array value and listbox will operate correctly.
memclear
dim reqarray(8)
baudrate 115200
serialtimeout 10
serial2begin 115200, 4 , 5
choice="Real Time Datum"
gosub [UpdateData]
'
[GUI]
wprint "MQST MPPT Solar Charge Controller 8-3-2016" & "<BR>"
wprint " running on ESP Basic Version 3.0a23" & "<BR>" & "<BR>"
dropdown choice,"Rated Datum,Real Time Datum,Real Time Status,Statistical Parameters,Setting Parameters,Switch Parameters,Discrete Parameters"
button "refresh",[refresh]
wprint "<BR>" & htmlvar(choice) & "<BR>" & "<BR>"
'
wprint htmlvar(Stat0)
wprint htmlvar(Stat1)
wprint htmlvar(Stat2)
wprint htmlvar(Stat3)
wprint htmlvar(Stat4)
wprint htmlvar(Stat5)
wprint htmlvar(Stat6)
wprint htmlvar(Stat7)
wprint htmlvar(Stat8)
wprint htmlvar(Stat9)
wprint htmlvar(Stat10)
wprint htmlvar(Stat11)
'
'timer 5000,[TimesUp]
wait
[refresh]
gosub [UpdateData]
returngui
wait
[TimesUp]
gosub [UpdateData]
wait
[UpdateData]
Stat0 = ""
Stat1 = ""
Stat2 = ""
Stat3 = ""
Stat4 = ""
Stat5 = ""
Stat6 = ""
Stat7 = ""
Stat8 = ""
Stat9 = ""
Stat10 = ""
Stat11 = ""
'
if choice == "Rated Datum" then
gosub [Rated_Datum]
end if
'
if choice == "Real Time Datum" then
gosub [Real_Time_Datum]
end if
'
if choice == "Real Time Status" then
gosub [Real_Time_Status]
end if
'
if choice == "Statistical Parameters" then
gosub [Statistical_Parameters]
end if
'
if choice == "Setting Parameters" then
gosub [Setting_Parameters]
end if
'
if choice == "Switch Parameters" then
gosub [Switch_Parameters]
end if
'
if choice == "Discrete Parameters" then
gosub [Discrete_Parameters]
end if
'
return
'
[request]
response="Time Out!"
'return
reqarray(0)=1
return
reqarray(1)=4
MSB=int(address/256)
LSB=address-(MSB*256)
reqarray(2)=MSB
reqarray(3)=LSB
MSB=int(count/256)
LSB=count-(MSB*256)
reqarray(4)=MSB
reqarray(5)=LSB
response="Timeout!"
return
'
[Rated_Datum]
address=12288 ' 0x3000
count=1
gosub [request]
ARV=response
Stat0 = "Array Rated Voltage = " & ARV & " Volts" & "<BR>"
return
'
[Real_Time_Datum]
address=12544 ' 0x3100
count=1
gosub [request]
PVAIV=response
Stat0 = "PV Array Input Voltage = " & PVAIV & " Volts" & "<BR>"
return
'
[Real_Time_Status]
address=12800 ' 0x3200
count=1
gosub [request]
BS=response
Stat0 = "Battery Status = " & BS & " Volts" & "<BR>"
return
'
[Statistical_Parameters]
address=13056 ' 0x3300
count=1
gosub [request]
MPVVT=response
Stat0 = "Maximum PV Voltage Today = " & MPVVT & " Volts" & "<BR>"
return
'
[Setting_Parameters]
address=36864 ' 0x9000
count=1
gosub [request]
BT=response
Stat0 = "Battery Type = " & BT & "<BR>"
return
'
[Switch_Parameters]
address=0 ' 0x0000
count=1
gosub [request]
CDS=response
Stat0 = "Charging Device Status = " & CDS & "C" & "<BR>"
return
'
[Discrete_Parameters]
address=8192 ' 0x2000
count=1
gosub [request]
OTD=response
Stat0 = "Over Temperature (Device) = " & OTD & "C" & "<BR>"
return