Technical Support will sometimes receive a complaint from a customer that their database is crashing. More often it is something specific to code within a compiled database which is causing this problem.
One way to help determine if there is a problem with the code is to use a feature of the 4D Compiler called Range Checking. This allows a message to be displayed to the user that an error occurred, rather than crash the computer.
Examine the following code segment:
Here you can see two problems with this code. First, there are only 5 elements in the array and the code addresses six. Second, the string length is set to ten, and there are items longer than ten characters.
If you were to compile this database and then execute the above method, you would find that it will crash your computer when range checking is turned off. If you turn on range checking, you will get a message that reads:
A runtime error occurred at line number: 3
When executing the method:
The destination string is smaller than the source.
Is there anything wrong with the syntax of any of the lines of code? No.
Is there anything wrong with the logic of the lines of code? Absolutely!
The 4D Compiler does not check that your code is logical, only the syntax. This is why the code will compile just fine, but cause a crash when it is executed.
The following is a true story:
Customer: My database is crashing.
TS Rep: Is your database compiled?
TS Rep: Is range checking turned on?
TS Rep: Can you turn it on, recompile and then test it?
Customer: No. When range checking is turned on, my users see error messages on their screen. I don't want them to see the error messages.
Although this makes for a funny story, it does show a problem with the code in the database rather than a problem with the 4D software. Once you've used the software for some time and performed many tests, then perhaps it may be safe to turn range checking off. But until then, better safe than sorry....