Maintaining Test Variable State within a Loop

Hello Zusammen,

I am trying to define a test variable within Teddy using a loop function. However, I am facing an issue where the value of my ‘#test-dir’ variable is being reset to zero in each iteration of the loop. I am looking for a more efficient approach to prevent this without resorting to lengthy logical functions with IF statements. I attempted using LET instead of STO, but unfortunately, it did not give me the desired result.

Below is an extract of my code:

STO#test_dir 0  
.
.
 loop#i 4
        LET#UZ @(#NODE_tab(#i),UZ)
        if (#UZ>0)
            STO#test_dir #test_dir=#test_dir+1
        else
            STO#test_dir #test_dir=#test_dir-1
        endif
endloop

Thanks in advance
ach


I think, it is the wrong order:
#test_dir=#test_dir+1; STO#test_dir (instead of: STO#test_dir #test_dir=#test_dir+1)

thank you for your reply.
Unfortunately, the suggested solution did not resolve the issue. After making the changes as per your advice, this error message is being displayed. the STO/LET is needed.

error msg

STO/LET: It’s yet the syntax (LET is required for computation):
let#test_dir #test_dir+1 (or: let#test_dir=#test_dir+1)

And: STO ist only at the modul-closure necessary. Every STO needs a little writetime to cdb, so a “ending-STO only” could be faster.