Skip to content

dev_set_check๐Ÿ”—

Only available for HDevelop

Short description๐Ÿ”—

dev_set_check โ€” Specify the error handling in HDevelop.

Signature๐Ÿ”—

dev_set_check( : : Mode : )

Description๐Ÿ”—

dev_set_check specifies how HDevelop has to react in case of an error, i.e., if the return state of an operator is not 2 (H_MSG_TRUE).

If Mode has the value 'give_error'โ€”which is the system defaultโ€”an erroneous operator call will throw an exception, that can be caught within the HDevelop program by the catch statement. However, if there is no surrounding try-catch block in the HDevelop program and the program is executed within HDevelop, the program execution stops at the erroneous operator and an error message box is opened to display the error text. In addition, the appropriate operator call is entered into the Operator Window, so that the user can easily edit and possibly correct the parameters of the erroneous operator call. If the procedure was called from HDevEngine and the exception is not caught within the HDevelop program, an HDevEngineException object is thrown and the procedure is left.

If Mode is set to โ€˜~give_errorโ€™, the error will be ignored and the program continues with the next operator. OpRef{dev_set_check (โ€˜~give_errorโ€™)} is intended to be used in connection with dev_error_var, which allows to check the result state that is returned by the operator calls.

Attention๐Ÿ”—

Using the code export feature of HDevelop, the code that is generated for this operator may have a different behavior than the related HALCON operator. For a detailed description of the code export of HDevelop graphics operators into the different programming languages see in the โ€œHDevelop User's Guideโ€ the chapter Code Export -> General Aspects of Code Generation -> Graphics Windows.

Parameters๐Ÿ”—

Mode (input_control) string โ†’ (string)

Mode of error handling.

Default: 'give_error'

Example๐Ÿ”—

(HDevelop)


dev_close_window ()
dev_open_window (0, 0, 512, 512, 'black', WindowHandle)
dev_error_var (Error, 1)
dev_set_check ('~give_error')
FileName := 'wrong_name'
read_image (Image, FileName)
ReadError := Error
if (ReadError != H_MSG_TRUE)
  write_string (WindowHandle, 'wrong file name: '+FileName)
endif
* Now the program will stop with an exception
dev_set_check ('give_error')
read_image (Image, FileName)

Result๐Ÿ”—

If the values of the specified parameters are correct, dev_set_check returns 2 (H_MSG_TRUE). Otherwise, an exception is raised and an error code returned.

Combinations with other operators๐Ÿ”—

Combinations

Possible successors

dev_error_var

See also

set_check, try, catch, endtry

Module๐Ÿ”—

Foundation