Promotic
WikipediaLinkedInYoutubeTwitterFacebook

GetLastError - method of object PmBuffer

Description:
Returns the attribute of the last error.
Syntax:
Long GetLastError([Boolean bClear])
Calling:
bValue = PmBuffer.GetLastError(false)
Parameters:
bClear[optional] (Boolean) Specifies whether to zero the error attribute after reading it.
false - The attribute is not zeroed (stays unchanged) after reading.
true (default) - The attribute is zeroed after reading.
Return Values:
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 returned 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 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 - attribute indicating that an error occured. By calling it, the internal attribute is zeroed.

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

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice