KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Different ways to validate execution of 4D Write plugin commands
PRODUCT: 4D Write | VERSION: 14.1 | PLATFORM: Mac & Win
Published On: October 6, 2014

There are a couple of ways to perform error checking on 4D write plugin commands. The first way to detect if a 4D write plugin command has executed properly is to obtain the error number after the execution of the command using WR Error number. WR Error number returns the error number of the last 4D write plugin command executed; or 0 if no error occurred. The text of the error can be found using WR Error text.

WR PRINT($area;wr print values;1)
$Error:=WR Error number ($area)
If ($Error#0)
  ALERT(“Error number ” + String($Error) + “: “+ WR Error text ($Error))
End if


Another way to do error checking is to use the command WR ON ERROR. This method installs an error handler that will detect if an error occurs after the execution of every 4D write plugin command.
WR ON ERROR ("WRGetError") // install error handler
WR PRINT($area;wr print values;1)


The WRGetError handler method below:
//Method: WRGetError
//Description: Alert error number and text if error occurs on write plugin command

C_LONGINT($1;$2)
C_TEXT($3)
ALERT("Error number "+String($2)+": "+$3)