Applies To:
  • CitectSCADA 5.41 Service Pack A
  • CitectHMI 5.41 Service Pack A

I have a cicode function containing a long WHILE DO loop which never executes to completion. It termiates early, sometimes without any error message, and sometimes it causes Citect to crash. In Page Table Cicode in the kernel I see that the code thread remains in a run state. 

The problem could be in the size of a WHILE DO or FOR DO loop in your code. A limit is reached at around 965 lines of code within a WHILE Loop. After which, if your loop is longer than 965 lines then the pointer back to the top of the loop gets corrupted and so the while condition never gets checked again, and the code appears to terminate.

You can verify that the pointer for the WHILE DO loop is being corrupted by adding [General]debugcode = 1 to the citect.ini. Then recompile the project and a file called code.lst will get generated in the BIN directory. View it with a text editor and you'll see that it contains a list of all the compiled cicode within the project (and in the order in which it is compiled). If you search for your function you'll see that when the problem occurs, the Branch line is incorrect. It should branch back to the first line of the loop but instead it tries to branch to a bogus line number which probably doesn't even exist. (eg a very large number)

Citect has confirmed this to be a problem in CitectHMI/SCADA version 5.21 to 5.41. We are researching this problem and will post new information here as it becomes available.