Applies To:
  • CitectSCADA 2.xx, 3.xx, 4.xx, 5.xx

When I create a form in Citect and enter my data, Citect crashes when I press the OK button. My code looks like this.

INT hForm;

STRING sBuffer; //Local String Variable for Edit Field
hForm = FormNew("Test", 10, 10, 1); //Create a new form
FormEdit(1, 1, sBuffer, 5); //Add an Edit Control
FormButton(1, 7, "OK", 0, 1); //Add an OK Button
FormRead(1); //Put form on screen without blocking Cicode



The problem is that the form system is trying to write back the information to the buffer for the edit field. The variable being used is a local variable and has gone out of scope as FormRead(1) was called which does not block the Cicode.  In versions prior to 5.2 there is no way to protect against this potential problem and can be caused by any form item that writes back to a buffer. 

The solution is to make sBuffer a global variable, or to restructure the code so that FormRead(0) used in place of FormRead(1).

CIT has confirmed this to be a problem in Citect for Windows version 2.xx to 5.10.   This problem has been fixed in version 5.20.