Applies To:
  • CitectSCADA 7.0
  • CitectHMI 7.0

Summary:

Some cicode function may allocate (reserve) some memory to place its return result to that buffer. In this case, taking StrMid as an example, what may happen if you are trying to read more characters that is out of bound from the source string such as the following:

SomeVariable = StrMid ("ABCDEF", 3, 4)

The return result is expected to be "DEF*" considering '*' as a null as the number of characters to get is more than the total number of characters available from the offset to the end of the string. 


Solution:

Having a case as above, there will be some consequences inflicted on how the memory is being processed. For example, a known case is where there is a situation which after the function StrMid() is specified wrongly as above, we do a TagWrite to a MEMORY tag.

This will results in the memory tag not being written at all and in order for the memory tag to be written properly we must do TagWrite() twice (the first one will not write anything). A possible cause is that there is a corruption in the memory resulting from the function StrMid trying to read character that is out of bounds from the source string.

Be careful when using such cicode function as memory corruption can cause many different issue. 


Keywords:
 

Attachments