Bug in array assignment/recall
Posted: Mon Sep 12, 2016 1:56 am
This is bizarre! I'm setting up arrays, parsing string values into these arrays (why I do this is another matter) but when I recall values from these arrays, they are way wrong!
So I worked on this, adding WPRINT statements to the initialization loop to find problems there too. Seems that V=VAL(TEMPS) throws an error but changing TEMPS to TEMP$ does work. That looks like a whole different bug. But changing the code to isolate the problem to array write/read gives me the following code which still does not work:
My recalled values are:
70975523162658884501752.25443 - 0
0 - 0
0 - 0
0 - 0
0 - 0
0 - 0
293882386519807514702051776112.05726 - 0
72053216539090128023303.80509 - 0
0 - 0
293882386519807514702051776112.05726 - 0
1112820201451986124041582115.75122 - 0
Uhm... I'm stumped.
Code: Select all
let dev_name="temp1 temp2 temp3 temp4 temp5 temp6 flood pump pswitch power lowp"
let dev_type_str="88888875155"
let dev_pin_str= "0 1 2 3 4 5 6 3 4 5 12"
dim dev_value(20)
dim dev_new_val(20)
dim dev_pin(20)
dim dev_type(20)
for t=1 to len(dev_type_str)
let temps= mid(dev_type,t,1)
let dev_type(t)=val(temps)
let temps=word(dev_pin_str,t)
let dev_pin(t)=val(temps)
next t
' Now recall and report from arrays
cls
for t=1 to len(dev_type_str)
wprint dev_type(t)
wprint " "
wprint dev_pin(t)
wprint "<br>"
next t
wait
So I worked on this, adding WPRINT statements to the initialization loop to find problems there too. Seems that V=VAL(TEMPS) throws an error but changing TEMPS to TEMP$ does work. That looks like a whole different bug. But changing the code to isolate the problem to array write/read gives me the following code which still does not work:
Code: Select all
let dev_name="temp1 temp2 temp3 temp4 temp5 temp6 flood pump pswitch power lowp"
let dev_type_str="88888875155"
let dev_pin_str= "0 1 2 3 4 5 6 3 4 5 12"
dim dev_value(20)
dim dev_new_val(20)
dim dev_pin(20)
dim dev_type(20)
cls
wprint "Assing values to arrays...<br>"
for t=1 to len(dev_type_str)
let temp$= mid(dev_type_str,t,1)
let v=val(temp$)
wprint v
wprint " - "
let dev_type(t)=v
let temp$=word(dev_pin_str,t)
let v=val(temp$)
wprint v
wprint "<br>"
let dev_pin(t)=v
next t
wprint "<br>Recalling values...<br>"
for t=1 to len(dev_type_str)
wprint dev_type(t)
wprint " - "
wprint dev_pin(t)
wprint "<br>"
next t
wait
My recalled values are:
70975523162658884501752.25443 - 0
0 - 0
0 - 0
0 - 0
0 - 0
0 - 0
293882386519807514702051776112.05726 - 0
72053216539090128023303.80509 - 0
0 - 0
293882386519807514702051776112.05726 - 0
1112820201451986124041582115.75122 - 0
Uhm... I'm stumped.