Promotic

GetLastError - method of the PmBuffer object

Description:
Returns the flag of the last error.
Syntax:
Long GetLastError([Boolean bClear])
Parameters:
bClear[optional] (Boolean) Specifies whether to zero the error flag after reading it.
false - The flag is not zeroed (stays unchanged) after reading.
true (default) - The flag is zeroed after reading.
Return value:
0 - If no error occured.
Non-zero value - If error occured.
Note:
If multiple operations are executed in sequence then it is possible to test completion of each operation (valid return value or internal position pointer shift by the correct number of bytes).
It may be quite elaborate to test this after each operation, so there is a more simple way to do this. By this method, it is possible to check if error occured after all operations are completed. This error is deleted after calling this method with the true parameter.

This method is also functional in Web panels.
Example:
JavaScriptSelect and copy to clipboard

var buf = Pm.CreatePmBuffer();
buf.SetInt16(-2, 10);
var nVal = buf.GetInt32(0);   // Invalid calling. The buffer contains only 2 bytes so it is not possible to read 4 bytes.
var nErr = buf.GetLastError();   // Returns non-zero value - flag indicating that an error occured. By calling it, the internal flag is zeroed.

History:
Pm9.00.05: Created
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.