I have the following from a DB with 49 weekly columns. I have a procedure that checks each column to find if any are missing. The procedure fails when it gets to WK31. I used the following to check the procedure and noted an error in counter (lxN) vs the column name.
axFld= axFld+¶+pattern(lxN,"## ")+info(“fieldname”)
The results (truncated for clarity) are:
Note that the value of lxN jumps from 31 to 33, for no reason. I have tried int( and round( and get the same result.
Definately something screwy here. Even using this simplest form of code shows the problem.
This produces (partial):
If I change the initial value of x from 0 to 1 then item 32 shows but item 33 is missing. If, however, I use this code it all works properly.
So I would adjust your original sample code to this:
axFld= axFld+¶+pattern(i,"## ")+info(“fieldname”)
This is a very weird bug. It seems to happen only if the assignment statement is the first statement after the loop statement. In that case, once every 33 times Panorama jumps back up to the top of the loop after the assignment (it’s not a calculation error, it’s a program flow error). This causes the assignment to run twice. I don’t know why, and I have written this up for further investigation.
I think Gary’s solution of using a for loop is the best solution for now. But I was also able to get it to work simply by adding a NOP statement right after the loop and before the assignment.
It doesn’t have anything to do with the original question, but in Panorama 6 it was common practice to scan an array with a loop incrementing a variable, like this:
let element = array(theArray,n,separator)
.... do something
n = n+1
Since the assignment isn’t the first statement in the loop, this technique doesn’t trigger the bug.
Note: In Panorama X, there’s a much better way to scan an array:
... do something
Thanks. I will try these.
I ran this out for a few hundred iterations and it appears the skipped numbers hit on or around each 32 (2^5) cycles.
just tried the following:
now it doubles the values every 32 cycles
and this works
Thanks all, hope you find the bug
The assignment to increment IxN is unnecessary. All you need is one line in the loop:
Also found that adding an “Until formula” before the endloop works to exit the loop
Sure, but there is no reason to do it that way. In fact, it will make the loop slower. Better to just put 130 instead of 500 in the for statement if that’s what you want to do, and use endloop at the bottom.