由于无法修改变量,因此计数器等由 IDataHolder 数组实现,其中计数器通过将值与前一个值相加来获取值,然后在前进到下一个位置之前将其存储在当前位置。这种机制在以下扫描脚本中部分中断,其中读取变量似乎会更改其值,我想了解原因:
# Sum Test
# Build sum starting at the left end
def sum;
if (BarNumber() < 5) {
if (BarNumber() == 1) {
sum = 1;
} else {
sum = sum[1] + 1;
}
} else {
sum = sum[1]; # This causes the problem.
#sum = Double.NaN;# alternative: does not change previous value but useless.
}
# Test that the first sum entry is 1 as expected
plot scan = GetValue(sum, BarNumber() -1) == 1;