KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Range checking error are not caught ON ERR CALL in compiled mode
PRODUCT: 4D | VERSION: 16 | PLATFORM: Mac & Win
Published On: September 8, 2017

Range checking errors do not trigger ON ERR CALL when running in compiled mode.

An example of a range checking error is:

ON ERR CALL("ErrorHandler") // set error handler
ARRAY TEXT($at;0) // size array to 0
$at{1}:="text" // access element that does not exist
ON ERR CALL("") // clear error handler


The code above sizes an array ($at) to 0 elements, then attempts to access element #1 ($at{1}) even though it does not exist.

If running compiled and range checking is disabled, then this code could crash 4D.
If running compiled and range checking is enabled, then this code would produce a range checking error instead of crashing.

The sample code above is written to use an error handler, but if the code were executed in compiled mode the error handler will not be triggered. Instead a runtime error is displayed.


This behavior is exapected and has existed for a very long time.

The developer should check the size of the array before attempting to manipulate an element like in this example:
If (Size of array($at)>=1)
    $at{1}:="text" // access element only if it exist
End if

See Also: